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
https://forums.phpfreaks.com/topic/215330-missing-one-record-from-my-display/
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);

 

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.