remybink Posted August 26, 2011 Share Posted August 26, 2011 this is my nav menu code <ul> <li><a href='fountains_page.php?id=all'>all fountains</a></li> <li><a href='fountains_page.php?id=garden'>garden fountains</a></li> <li><a href='fountains_page.php?id=wall'>wall fountains</a></li> </ul> this is my script require('dbconnect.php'); $id = $_GET['id']; if($id = all){ $records = "SELECT * FROM (fountains)"; }else{ if ($id = garden){ $records = "SELECT * FROM (fountains) WHERE wall='no'"; }else{ if($id = wall){ $records = "SELECT * FROM (fountains) WHERE wall='yes'"; } } } $query_records = mysql_query($records); $num_records = mysql_num_rows($query_records); if ($num_records == 0) { echo "The menu is closed for now."; } else{ $i=1; } echo 'We have'.' '.$num_records.' '.'fountains for your consideration<br />Please visit our store to view hundreds of styles.<br />'; echo $id; $errors = array(); // initialize error array Here is the link http://www.mywebsitepaid.com/stonemans/fountains_page.php I can't get the 'id' to pass. What am I doing wrong? I did another site fine, but here I messed something up. Quote Link to comment https://forums.phpfreaks.com/topic/245724-getid-to-pass-from-nav-menu/ Share on other sites More sharing options...
teynon Posted August 26, 2011 Share Posted August 26, 2011 Lots of issues with your code. 1) You are using an assignment operator. (=) If you are comparing you need to use ==. 2) When you are comparing strings, you have to put quotes around it to define it as a string. "" 3) You don't need to do if (blah) { } else { if (blah) }. You can do if (blah) {} else if (blah) {} else { } if($id == "all"){ $records = "SELECT * FROM (fountains)"; }else{ if ($id == "garden"){ $records = "SELECT * FROM (fountains) WHERE wall='no'"; }else{ if($id == "wall"){ Quote Link to comment https://forums.phpfreaks.com/topic/245724-getid-to-pass-from-nav-menu/#findComment-1262088 Share on other sites More sharing options...
remybink Posted August 26, 2011 Author Share Posted August 26, 2011 $id = $_GET['id']; if($id == "all"){ $records = "SELECT * FROM (fountains)"; }else if($id == "garden"){ $records = "SELECT * FROM (fountains) WHERE wall='no'"; }else{ $records = "SELECT * FROM (fountains) WHERE wall='yes'"; } hahaha -- you rock!!!! Quote Link to comment https://forums.phpfreaks.com/topic/245724-getid-to-pass-from-nav-menu/#findComment-1262092 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.