I am passing a variable from a link on one page to another to select a query from a db table. My anchor tags end with "/file.php?id=2" I have id's set up from 1 to 7. On the page that is linked to I have this code set up....
if ($id = 1){
$sql = 'SELECT FROM new_mowers WHERE cut BETWEEN 17 AND 23 ORDER BY price LIMIT 0, 30';
}
//search for mowers up to 36 inches
if ($id = 2){
$sql = 'SELECT FROM new_mowers WHERE cut BETWEEN 23 AND 37 ORDER BY price LIMIT 0 , 30';
}
//38-48 search
if ($id = 3){
$sql = 'SELECT FROM new_mowers WHERE cut BETWEEN 37 AND 49 ORDER BY cut LIMIT 0 , 30';
}
//50-59 search
if ($id = 5){
$sql = 'SELECT FROM new_mowers WHERE cut BETWEEN 49 AND 59 ORDER BY cut LIMIT 0 , 30';
}
//60-62 search
if ($id = 6){
$sql = 'SELECT FROM new_mowers WHERE cut BETWEEN 60 AND 62 ORDER BY brand LIMIT 0 , 30';
}
//70+ search
if ($id = 7){
$sql = 'SELECT FROM new_mowers WHERE cut > 70 ORDER BY brand LIMIT 0 , 30';
}
No matter which link is clicked on, it always runs the query for ?id=7 (the last one) Why is this and how can I get it to recognize the $id variable as 1 or 2 or 3... and run that query?
Does the $id variable need to be passed via a form for it to work or maybe the if statements need to be nested?
Thanks for any help you can give me.
Mellow