Specific class for loop - first and last
Posted: Tue Jan 13, 2009 4:44 pm
Hi there.
I'm new to this forum aswell as php and I'm having some trouble, and would appreciated some help.
I have this simple query
and the following xhtml
The css and php work fine. The problem is that the grid I'm working on is very tight and in doing this loop, I'm loosing control over my css.
There is a row with 3 items on it. Doing it manually, I apply a class to the first and second items to fit the grid......or a class to the middle item. The classes affect the margins. This means that everything fits nice and tightly. I do this for each row.
With the php, I'm looking for a way to single out either the 1st and 3rd items on each row so I can apply a different css class to them.
Is this possible?
Theoretical answers probably won't work as I'm a designer not a developer..ergo, it would be lost on me.
Thanks in advance.
I'm new to this forum aswell as php and I'm having some trouble, and would appreciated some help.
I have this simple query
Code: Select all
mysql_select_db($database_conn1, $conn1);
$query_portfolio = "SELECT * FROM portfolio ORDER BY dateadded DESC";
$portfolio = mysql_query($query_portfolio, $conn1) or die(mysql_error());
$row_portfolio = mysql_fetch_assoc($portfolio);
$totalRows_portfolio = mysql_num_rows($portfolio);
Code: Select all
<?php do { ?>
<div class="grid_3">
<div>
<img src="<?php echo $thumbnail->Execute(); ?>" alt="<?php echo $row_portfolio['name']; ?>" class="pimage" />
</div>
<div>
<h2 class="mtp10"><?php echo $row_portfolio['name']; ?></h2>
<?php echo $row_portfolio['desc']; ?>
</div>
</div>
<?php } while ($row_portfolio = mysql_fetch_assoc($portfolio)); ?>
</div>
There is a row with 3 items on it. Doing it manually, I apply a class to the first and second items to fit the grid......or a class to the middle item. The classes affect the margins. This means that everything fits nice and tightly. I do this for each row.
With the php, I'm looking for a way to single out either the 1st and 3rd items on each row so I can apply a different css class to them.
Is this possible?
Theoretical answers probably won't work as I'm a designer not a developer..ergo, it would be lost on me.
Thanks in advance.