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>";
}
?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.