Results 1 to 9 of 9
Mar 14, 2013, 09:06 #1
- Join Date
- Dec 2005
- 0 Post(s)
- 0 Thread(s)
Add class to third element - IF Else %
I'm running sum basic content from a XML file and have the below which outputs things ok.
My problem is when I try and use an if else statement to supply a div class="last" to every third element, it adds it to all the div elements.
Wondering what I'm doing wrong?
Can anybody spot the problem with syntax below?
<?php foreach ($hotels->hotel as $hotel): ?>
<?php if($i % 3 == 0) : ?>
<?php else: ?>
<?php endif; ?>
<img src="images/<? echo $hotel->img->name ?>">
<h3><? echo $hotel->name ?></h3>
<p><? echo $hotel->description ?></p>
<p><? echo $hotel->address->postcode ?></p>
<? endforeach ?>The more you learn.... the more you learn there is more to learn.