Hi All,
the code below displays the 1st product in the table a 2nd time, and doesn't display the 2nd product at all. Currently only 2 products in the products table. Something amiss in my logic/code..?
<?php
$db = mysql_connect("localhost", "root", "grunger");
if (!$db) {
echo "no connection because " . mysql_error();
exit;
}
mysql_select_db("status", $db);
if (isset($_REQUEST[maker_id])){
$maker_id = $_REQUEST[maker_id];
$result = mysql_query("SELECT Products.product_qty, Products.product_id, Products.product_name,
Products.product_price, Products.product_model_number, Makers.maker_detail
FROM Products INNER JOIN Makers ON Products.maker_id = Makers.maker_id
WHERE Makers.maker_id = '$maker_id'");
if (!$result) {
echo "Query failed: " . mysql_error();
exit;
}
$num = mysql_num_rows($result);
$myrow=mysql_fetch_array($result);
$maker = $myrow["maker_detail"];
echo "<tr align=\"center\"><td colspan=\"3\">Status-$maker
</td></tr><tr><td>Product Name</td><td>Quantity</td><td>More Details</td></tr><br>";
if ($num < 1) {
echo "<tr align=\"center\"><td colspan=\"3\">Sorry, no products in that category</td></tr>";
}
for ($i=0; $i < $num; $i++){
$product_name = $myrow["product_name"];
$product_price = $myrow["product_price"];
$product_model_number = $myrow["product_model_number"];
$product_id = $myrow["product_id"];
$product_qty = $myrow["product_qty"];
echo "<tr align=\"center\"><td> $product_name</td><td>$product_qty
</td><td><a href=\"productdetails.php?product_id=
$product_id\">More Details</a></td></tr><br>";
}
}
EDIT: Ok, problem fixed..moved the $myrow line into the loop..cheers..