Jump to content

Missing one record from my display...


RynMan

Recommended Posts

Hey guys

 

I'm not amazing at PHP, but know just enough to be dangerous.  :(

 

Basically I'm trying to get these records from my database to display in rows of 4.  For some reason every time, I'm missing a record (the first record returned in my query).  It's probably something simple is my code.  Would be grateful if anyone could lend a suggestion. 

 

 

 <?php          $a=0;         $b=3;                    while ($ArrayData = mysql_fetch_array($QueryData)) {                    //if a=0, start new row            if ($a==0) {            echo '<tr>';            }                    //create cell          //if thumbnail exists, use it, otherwise throw in the unavailable image          if ($ArrayData["PhotoThumb"]!="") {          $ImageToUse = $ArrayData["PhotoThumb"];           } else {          $ImageToUse = "image_unavailable_thumb.jpg"; }          echo '             <td width="33%"  align="center" valign="top"><p><a href="item.php?ItemID='.$ArrayData["ItemID"].'"><img src="images/'.$ImageToUse.'" border="0" /></a></p>              <p><a href="item.php?ItemID='.$ArrayData["ItemID"].'" class="cart_body_text">'.$ArrayData["ItemName"].'</a><br />                 <span class="style1"> <strong>$'.sprintf("%01.2f", $ArrayData["UnitPrice"]).'</strong></span><br />              </p>              </td>';                 //increment by 1         $a++;                //if a = 3 then close the row using </tr>, ready to start a new one        if ($a==$b) {        echo '        </tr>';                //reset counter, ready to start new row        $a=0;        }        }                     if ($a > 0 ) {           echo '</tr>';        }              ?>

 

 

Thanks guys!

Link to comment
Share on other sites

Ah yep, sorry! :(

 

 

$QueryData = mysql_query("SELECT * FROM `Items` WHERE ItemCategoryShort = '$ItemCategory' ORDER BY UnitPrice ASC", $connection);    if (!$QueryData) {     die("Database query failed" . mysql_error()) ;    }    $ArrayData = mysql_fetch_array($QueryData);

 

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.