3 posts by 1 authors in: Forums > CMS Builder
Last Post: September 18, 2012   (RSS)


I'm working on a website with TABS navigation, where every tab should get a record title. Usual coding for this is:
<ul class="tabs">
<li><a href="#tab1">RecordTitle 1</a></li>
<li><a href="#tab2">RecordTitle 2</a></li>
<li><a href="#tab3">RecordTitle 3</a></li>

So, depending on how many records I got, the value of "#tab1" should be increased with +1 for every next record... keeping in mind that the amount of records for some products may vary from 1 to 10.

Is there a way to achieve this with php please ?


Re: [kovali] Records count and adding +1

Searching the forum I came up with this solution:

<ul class="tabs">
<?php $recordCount = 0; ?>
<?php foreach ($haakarmsystemenRecords as $record): ?>
<li><a href="<?php echo $record["#tab".++$recordCount];?>"><?php echo htmlencode($record['title']) ?></a></li>
<?php endforeach ?>

The titles are showing ok now in the tabs, but the actual links are not working: Instead I get: "Notice: Undefined index: #tab1 in /home/ajkhydro/public_html/test.php on line 139"