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

Hi,

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>
</ul>

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 ?

Thanks!

Re: [kovali] Records count and adding +1

Got it working now with this adjustment to the code:

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

<?php endforeach ?>
</ul>