Hi,
I need to retrieve the max and min values of the price field in my db. I have a item table and a category table. I am using $_GET to get the category name and then I need to retrieve the min and maxvalues only for the items in that particular category.
I can get the max value of all items with this:
$maxvalue = "Select max(price) from item";
$resultmax = mysql_query($maxvalue);
$rowmax = mysql_fetch_array($resultmax);
echo $rowmax['max(price)'];
but when I try to join the tables to get the item with that value for a particular category:
$minvalue = mysql_query("Select i.min(price) from item i
left join category c
on i.cat_id = c.cat_id
WHERE c.cat_name = '".$_GET['category']."' and i.visible = 1");
$rowmin = mysql_fetch_array($minvalue);
echo $rowmin['min(price)'];
it doesn't work.
Any ideas?
Thanks.