helo surendan tnx for your cooperation: ill give you the whole code coz i applied your code but not running
code:
<?php
//connect to MySQL
$connect = mysql_connect("localhost", "root", "") or die ("Hey loser, check your server connection.");
//make sure weâre using the right database
mysql_select_db ("contents");
$querycats="SELECT CATEGORY,
ID_CATEGORY
FROM categories"; // Query to select all the categories to search all the items by using ID_CATEGORY variable.
$results=mysql_query($querycats)or die(mysql_error());
while ($rows = mysql_fetch_array($results)) {
echo "<br>\n";
extract($rows);
$searchcat = $ID_CATEGORY; //declaring variable for to get every corresponds value
echo "<b>$CATEGORY</b>"; //display the category
echo "<br>\n";
$queryitems="SELECT
DESCRIPTION,
QUANTITY
FROM items
WHERE ID_CATEGORY = '$searchcat'"; // Query to select all items....
//getting the value of every ID_CATEGORY it corresponds the specifi items
// this query implies to display items
$results2=mysql_query($queryitems)or die(mysql_error());
while ($items = mysql_fetch_array($results2)) {
extract($items);
echo "\n$DESCRIPTION\n"; // display the description and the quantity
echo "\n$QUANTITY";
echo "<br>";
}
}
?>
|