Problem with filter drop down menu

I have a problem which is getting the drop down menu to display each product from the group code chosen from the drop down menu. This is my code so far for this function:

if(isset($_GET[‘SageGroup’])) {
$sgroup = $_GET[‘SageGroup’];
} else {
$sgroup=100;
}

This is the query:

mysql_select_db($database_WebPriceUpdates, $WebPriceUpdates);
$query_Products = “SELECT * FROM Products WHERE SageGroup=’$sgroup’ ORDER BY Code ASC”;
$query_limit_Products = sprintf("%s LIMIT %d, %d", $query_Products, $startRow_Products, $maxRows_Products);
$Products = mysql_query($query_limit_Products, $WebPriceUpdates) or die(mysql_error());
$row_Products = mysql_fetch_assoc($Products);

This is the form for the drop down menu:

>Select specific group <?php do { ?> <?php echo $row_Sage_Groups['SageGroup']; ?> <?php } while ($row_Sage_Groups = mysql_fetch_assoc($Sage_Groups)); ?>

So far this code shows each group code but does not filter the products from the database into products based on the group code selected, which is what I would like to achieve. I believe I am missing some functions for this to work but I am not sure what as I am relatively new to php.

first let me tell you this is a completely unsecure script you are not validating $_GET[‘SageGroup’] before using it in a query.
next can’t you just do something simple like :
[php]
$a=mysql_query(“SELECT * FROM Products WHERE SageGroup=’$sgroup’ ORDER BY Code ASC”);
$b=mysql_fetch_assoc($a);
[/php]

to get the products

or do you need to do a while loop example:
[php]
$a=mysql_query(“SELECT * FROM Products WHERE SageGroup=’$sgroup’ ORDER BY Code ASC”);
while($b=mysql_fetch_assoc($a)){
echo $b[‘product’]."
";
}
[/php]
just a stab at it :smiley:

Sponsor our Newsletter | Privacy Policy | Terms of Service