Jump to content

[SOLVED] Mysql_Fetch_Row While Loop Question


sKunKbad

Recommended Posts

I've got a while loop that outputs the last 3 tips in a tipsntricks table, and I'd like to do something only for the first row. You can see there is a image in this while loop called anew.gif, and I only want it to be there for the first row(first pass through the loop). I only want to have to query the database one time, so I'm not interested in a solution with multiple queries (I already have one). I'm just doing this to learn MySQL better, but I'm stuck on this. Here's the code:

 

<?php
$thisBlurb = mysql_query("SELECT tipTitle, tipCode, tipNum FROM tipsntricks ORDER BY tipNum DESC LIMIT 3");
$color1 = "#f0e8fe";
$color2 = "#E9F3FB";
while($i = mysql_fetch_row($thisBlurb)) {
$row_color = ($i['2'] % 2) ? $color1 : $color2;
echo "<div style='width:420px; background-color:$row_color; border-top:dotted #567ACE 4px; padding:10px;'>";
echo "<h3 class='h2like'>";
echo "<img src='/img/wnew/anew.gif' alt='NEW! NEW! NEW!'/>  "; //this is the image that I only want output once.
echo "<a style='text-decoration:none;' href='/tips/".$i['2'].".php5'>".$i['0']."</a></h3>";
$blurb = preg_split('/<!--blurb split here-->/',$i['1'],-1);
echo "	{$blurb['0']}
<p><a style='text-decoration:none;' /tips/".$i['2'].".php5'><span style='font-weight:bold'>Show me more...</span></a></p></div>";
}
?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.