Hey!
On my homepage I want to click on the kitchens tab to display all products with the category ‘kitchens’ only to be displayed. On this kitchen page I want to display the data and to link to further info on that product.
When I click this link this error occurs;
[COLOR=”Red”]Notice: Undefined index: product_id in /var/www/vhosts/numyspace.co.uk/web_users/home/~unn_t006172/public_html/viewproduct.php on line 46
The problem is on this page; [url]http://www.numyspace.co.uk/~unn_t006172/kitchens.php
[COLOR=”Red”]kitchens.php
<?php
//connect to database
require_once (‘allsorts_dbconnect.php’);
//make a query to show all products with category = “kitchens”
$categorySQL = “select product_id, product_name, product_category, product_price from tblproducts where product_category = ‘Kitchen'”;
//execute that query
$rsCategories = mysql_query ( $categorySQL );
//display the start of the table
echo “<table border=”1″>n”;
//loop around the record set displaying each product on a new row
while($category = mysql_fetch_array( $rsCategories )){
$product_id = $category [‘product_id’];
$product_name = $category [‘product_name’];
$product_category = $category [‘product_category’];
$product_price = $category [‘product_price’];
echo “<tr><td>$product_id</td><td>$product_name</td><td>$product_price</td><td><a href=”viewproduct.php?product_id = $product_id”>read more…</a></td></tr>n”;
}//while
//end the table
echo “</table>n”;
?>
[COLOR=”Red”]viewproduct.php
<?php
// connect to the database
require_once (‘allsorts_dbconnect.php’);
// get the product_id from request stream
$product_id = $_REQUEST [‘product_id’];
// use that code in an sql statement to retrieve further details for that product
$productSQL = “select product_id, product_name, product_description, product_price from tblproducts where product_id = ‘$product_id'”;
// execute the sql query
$rsProduct = mysql_query($productSQL);
// get the records from the result set into variables
$product = mysql_fetch_array($rsProduct);
$product_id = $product [‘product_id’];
$product_name = $product [‘product_name’];
$product_description = $product [‘product_description’];
$product_price = $product [‘product_price’];
echo “<tr><td>$product_name</td><td>$product_description</td><td>$product_price</td></tr>n”;
// end the table
echo “</table>n”;
?>
Thanks in advance
Tom