List all records by default and filter if querystring
Posted: Tue Sep 18, 2007 12:03 am
Hi everyone,
I am using Dreamweaver and PHP and I just have a page that lists all products. I have a dropdown box that I can get to filter records based on an ID passed through querystring. I can't get the SQL right to default to list all records if there is no ID passed. I can make it one way or the other but can't seem to get both. Can someone help me with my SQL if thats the problem?
Here is my SQL portion:
Thanks for any help and let me know if you need anything else.
Buddy
I am using Dreamweaver and PHP and I just have a page that lists all products. I have a dropdown box that I can get to filter records based on an ID passed through querystring. I can't get the SQL right to default to list all records if there is no ID passed. I can make it one way or the other but can't seem to get both. Can someone help me with my SQL if thats the problem?
Here is my SQL portion:
Code: Select all
$colname_rsProduct = "0";
if (isset($_GET['cat'])) {
$colname_rsProduct = $_GET['cat'];
}
mysql_select_db($database_connWPA, $connWPA);
$query_rsProduct = sprintf("SELECT inventory.id, inventory.title, inventory.description, inventory.price, inventory.category AS 'cat', inventory.image1, inventory.image2, inventory.image3, categories.category FROM inventory INNER JOIN categories ON inventory.category = categories.id WHERE inventory.category= %s ORDER BY price ASC", GetSQLValueString($colname_rsProduct, "int"));
$rsProduct = mysql_query($query_rsProduct, $connWPA) or die(mysql_error());
$row_rsProduct = mysql_fetch_assoc($rsProduct);
$totalRows_rsProduct = mysql_num_rows($rsProduct);Buddy