Hi All,
the code as is below, displays all records correctly.
Problem is, trying to display the values of, product_type_detail and/or maker_detail in the 1st row.
For example, if the user chooses Cisco from Makers, the 1st row will look like this,
Status-Cisco
2nd Row like this,
Product Name Quantity More Details
3rd row would then display the record data,
Catalyst 2900 XL 2 <More Details>
Now, when I try to do this, I get all sorts of problems. How would you do it..?
<?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);
echo "<tr align=\"center\"><td colspan=\"3\"><center>Status-</center>
</td></tr><tr align=\"center\"><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>";
}
while($myrow = mysql_fetch_array($result)){
echo "<tr align=\"center\"><td>
".$myrow['product_name']."
</td><td>".$myrow['product_qty']."
</td><td><a href=\"productdetails.php?product_id
=".$myrow['product_id']."\">More Details</a></td></tr><br>";
}
}
else {
if (isset($_REQUEST[product_type_id])){
$product_type_id = $_REQUEST[product_type_id];
$result = mysql_query("SELECT Products.product_qty, ProductTypes.product_type_detail, Makers.maker_detail,
Products.product_id,
Products.product_name, Products.product_model_number
FROM Products INNER JOIN (ProductTypes
INNER JOIN Makers ON
Products.maker_id = Makers.maker_id) ON
Products.product_type_id = ProductTypes.product_type_id WHERE ProductTypes.product_type_id = '$product_type_id'");
if (!$result) {
echo "Query failed: " . mysql_error();
exit;
}
$num = mysql_num_rows($result);
echo "<tr align=\"center\"><td colspan=\"3\"><center>Status-</center></td>
</tr><tr align=\"center\"><td>Product Name</td><td>Quantity</td><td>More Details</td></tr><br>";
if ($num < 1) {
echo "<tr align=\"center\"><td colspan=\"3\"><center>Sorry, no products in that category</center></td></tr>";
}
while($myrow = mysql_fetch_array($result)) {
echo "<tr align=\"center\"><td>" .$myrow['product_name']."</td><td>
".$myrow['product_qty']."</td><td><a href=\"productdetails.php?product_id="
.$myrow['product_id']."\">More Details</a></td></tr><br>";
}
}
}
?>