vrmetro Posted April 3, 2008 Share Posted April 3, 2008 I am having a small problem, I need to display a list of products on a page from a database, but for some reason it is appearing double on the page, if anyone could help it would be great: <?php include "DBUtil.php"; if(!isset($dbh)) $dbh = FindDB('itiball'); $categories = array(); // Take a cat path , if set if(isset($_GET["id"])) { $cat_q = mysql_query("SELECT id,item_number,description,quantity,category,quote FROM liquidation ORDER BY id"); while($r = mysql_fetch_assoc($cat_q)) $categories[] = array($r["id"], $r["category"]); } else { $cat_q = mysql_query("SELECT id,item_number,description,quantity,category,quote FROM liquidation ORDER BY id"); while($r = mysql_fetch_array($cat_q)) $categories[] = array($r["id"], $r["category"]); } mysql_free_result($cat_q); foreach($categories as $item=>$cat_arr) { // Print out cat title $lq = mysql_query("SELECT * from liquidation ORDER BY item_number"); if(mysql_num_rows($lq)) { echo '<table border="0" cellspacing="1" cellpadding="2" width="700" class="prod_list" align="center">' . "\n"; echo '<tr>' . "\n"; echo '<td colspan="5" class="prod_list_hdr">'; echo '<b class="sans14" style="text-transform: uppercase;">'.$cat_arr[1].'</b><br>'; echo '<font class="sans12">'.$cat_arr[2].'</font>'; echo '</td>'; echo '</tr>' . "\n"; echo '<tr class="prod_list_top">'; echo '<td>Item Number</td>'; echo '<td>Description</td>'; echo '<td>Quantity</td>'; echo '<td>Price</td>'; echo '<td>Info</td>'; echo '</tr>' . "\n"; while($res = mysql_fetch_array($lq)) { echo '<tr>' . "\n"; echo '<td width="70">'.$res["item_number"].'</td>'; echo '<td width="200">'.$res["description"].'</td>'; echo '<td width="60">'.$res["quantity"].'</td>'; echo '<td width="40">'.$res["price"].'</td>'; echo '<td width="90" NOWRAP><a href="order_form.php?item_number='.$res["item_number"].'">To Order</a></td>'; echo '</tr>' . "\n"; } echo '</table>'; } else echo "Sorry, no products were found for this category."; mysql_free_result($lq); } // end foreach ?> Link to comment https://forums.phpfreaks.com/topic/99418-i-am-new-to-boards-and-php-need-help/ Share on other sites More sharing options...
cooldude832 Posted April 3, 2008 Share Posted April 3, 2008 honestly have to say that is very poor coding querying via a select in a loop is just something u don't do. try and look at your code your self and comment it out you should find the error Link to comment https://forums.phpfreaks.com/topic/99418-i-am-new-to-boards-and-php-need-help/#findComment-508724 Share on other sites More sharing options...
vrmetro Posted April 3, 2008 Author Share Posted April 3, 2008 Thank you for the help. Could you help me out, and kind of point me in right direction on what to change? Very new to php and somewhat lost Link to comment https://forums.phpfreaks.com/topic/99418-i-am-new-to-boards-and-php-need-help/#findComment-508740 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.