Jump to content

I am new to boards and php need help


vrmetro

Recommended Posts

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

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.