You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'ORDER BY Item_Title' at line 3here is my php code.
[PHP]<?php
$conn = mysql_connect ("localhost","root","")
or die (mysql_error ());
mysql_select_db ("stest",$conn) or die (mysql_error());
$display_block = "<h1>Categories</h1>
<p>select cat to see items.</p>";
$get_cats = "SELECT Cat_ID, cat_title, cat_description
FROM store_categories
ORDER BY cat_title";
$get_cat_res = mysql_query ($get_cats) or die (mysql_error());
if (mysql_num_rows($get_cat_res) < 1) {
$display_block = "<p><em>Sorry no cats to browse</em></p>";
} else {
while ($cats = mysql_fetch_array ($get_cat_res)) {
$cat_id = $cats [Cat_ID];
$cat_title = strtoupper (stripslashes ($cats[cat_title]));
$cat_desc = stripslashes ($cats [Cat_description]);
$display_block .= "<p><strong>
<a href=\"$_SERVER[PHP_SELF]?cat_id=$cat_id\">$cat_title</a></strong>
<br>$cat_desc</p>";
if ($_GET[Cat_ID] == $Cat_ID) {
$get_items = "SELECT Store_ID, Item_title, Item_Price FROM
Store_Items WHERE Cat_ID = $Cat_ID
ORDER BY Item_Title";
$get_item_results = mysql_query ($get_items) or die (mysql_error());
if (mysql_num_rows ($get_item_res) < 1 ) {
$display_block = "<p><em>Sorry no items in this category</em></p>";
} else {
$display_block .= "<ul>";
while ($items = mysql_fetch_array($get_item_res)) {
$item_id = $items[id];
$item_title = stripslashes($items[item_title]);
$item_price = $items[item_price];
$display_block .= "<li>
<a href=\"showitem.php?item_id=$item_id\">$item_title </a>
</strong> (\$$item_price)";
}
$display_block .= "<ul>";
}
}
}
}
?>
<html>
<head>
<title>My Categories</title>
</head>
<body>
<?php echo $display_block; ?>
</body>
</html>[/PHP]
thanks in advance for ur help.