usadarts Posted August 17, 2006 Share Posted August 17, 2006 I have the following in the header:[code]function categoryHandler(form){var URL = "http://www.Example.com/index.php?"+category.site.value+"=Y";window.location.href = URL;}[/code]The following form in the body:[code] <form name="category"> <div align="center"> <select name="site" size=1 onChange="javascript:categoryHandler()"> <option value=" ">Filter By Category</option> <option value="opt1">Option 1</option> <option value="opt2">Option 2</option> <option value="opt3">Option 3</option> <option value="opt4">Option 4</option> <option value="opt5">Option 5</option> <option value="opt6">Option 6</option> </select> </div> </form>[/code]I then have several IfElse statements to bring up page:[code]if($category == 'opt1') {$query = "SELECT * FROM `links` WHERE `opt1` = 'Y' and `approved` = 'Y' ORDER BY `title`";$result = mysql_query($query,$dbh) or die(mysql_error());} elseif($category == 'opt2') {$query = "SELECT * FROM `links` WHERE `opt2` = 'Y' and `approved` = 'Y' ORDER BY `title`";$result = mysql_query($query,$dbh) or die(mysql_error());} elseif($category == 'opt3') {$query = "SELECT * FROM `links` WHERE `opt3` = 'Y' and `approved` = 'Y' ORDER BY `title`";$result = mysql_query($query,$dbh) or die(mysql_error());} elseif($category == 'opt4') {$query = "SELECT * FROM `links` WHERE `opt4` = 'Y' and `approved` = 'Y' ORDER BY `title`";$result = mysql_query($query,$dbh) or die(mysql_error());} elseif($category == 'opt5') {$query = "SELECT * FROM `links` WHERE `opt5` = 'Y' and `approved` = 'Y' ORDER BY `title`";$result = mysql_query($query,$dbh) or die(mysql_error());} elseif($category == 'opt6') {$query = "SELECT * FROM `links` WHERE `opt6` = 'Y' and `approved` = 'Y' ORDER BY `title`";$result = mysql_query($query,$dbh) or die(mysql_error());}[/code]This does not work. It brings up the URL as:[code]http://www.dartsites.com/index.php?baseball=Y[/code]but does not filter the information as it should. It brings up everything in the database.Any ideas? Quote Link to comment Share on other sites More sharing options...
BillyBoB Posted August 17, 2006 Share Posted August 17, 2006 i think it is u have no method to go by like change ur code to ... :[code] <form name="category" method="post"> <div align="center"> <select name="site" size=1 onChange="javascript:categoryHandler()"> <option value=" ">Filter By Category</option> <option value="opt1">Option 1</option> <option value="opt2">Option 2</option> <option value="opt3">Option 3</option> <option value="opt4">Option 4</option> <option value="opt5">Option 5</option> <option value="opt6">Option 6</option> </select> <input type="submit" name="submit" value="Submit" /> </div> </form> <?php if($_POST['submit']) { if($category == 'opt1') { $query = "SELECT * FROM `links` WHERE `opt1` = 'Y' and `approved` = 'Y' ORDER BY `title`"; $result = mysql_query($query,$dbh) or die(mysql_error()); } elseif($category == 'opt2') { $query = "SELECT * FROM `links` WHERE `opt2` = 'Y' and `approved` = 'Y' ORDER BY `title`"; $result = mysql_query($query,$dbh) or die(mysql_error()); } elseif($category == 'opt3') { $query = "SELECT * FROM `links` WHERE `opt3` = 'Y' and `approved` = 'Y' ORDER BY `title`"; $result = mysql_query($query,$dbh) or die(mysql_error()); } elseif($category == 'opt4') { $query = "SELECT * FROM `links` WHERE `opt4` = 'Y' and `approved` = 'Y' ORDER BY `title`"; $result = mysql_query($query,$dbh) or die(mysql_error()); } elseif($category == 'opt5') { $query = "SELECT * FROM `links` WHERE `opt5` = 'Y' and `approved` = 'Y' ORDER BY `title`"; $result = mysql_query($query,$dbh) or die(mysql_error()); } elseif($category == 'opt6') { $query = "SELECT * FROM `links` WHERE `opt6` = 'Y' and `approved` = 'Y' ORDER BY `title`"; $result = mysql_query($query,$dbh) or die(mysql_error()); } }[/code] Quote Link to comment Share on other sites More sharing options...
usadarts Posted August 17, 2006 Author Share Posted August 17, 2006 That can't be it. I have other drop down menu's to help filter information and they all work but this one. Thank though Quote Link to comment Share on other sites More sharing options...
Jeremysr Posted August 17, 2006 Share Posted August 17, 2006 Change all the if($category to if($site Quote Link to comment Share on other sites More sharing options...
BillyBoB Posted August 17, 2006 Share Posted August 17, 2006 well sorry i couldnt help but Jeremysr got it im just not that good with code thats not my own Quote Link to comment Share on other sites More sharing options...
trq Posted August 17, 2006 Share Posted August 17, 2006 It should actually be...[code=php:0]if ($_GET['site'][/code] Quote Link to comment Share on other sites More sharing options...
usadarts Posted August 23, 2006 Author Share Posted August 23, 2006 I now have the following and it still does not work[code]function categoryHandler(form){var URL = "http://www.TestURL.com/index.php?"+category.site.value+"=Y";window.location.href = URL;}[/code][code] <form name="category"> <div align="center"> <select name="site" size=1 onChange="javascript:categoryHandler()"> <option value=" ">Filter By Category</option> <option value="opt1">option 1</option> <option value="opt2">option 2</option> <option value="opt3">option 3</option> </select> </div> </form>[/code][code]if($_GET['site'] == 'opt1') {$query = "SELECT * FROM `links` WHERE `opt1` = 'Y' and `approved` = 'Y' ORDER BY `title`";$result = mysql_query($query,$dbh) or die(mysql_error());} elseif($_GET['site'] == 'opt2') {$query = "SELECT * FROM `links` WHERE `opt2` = 'Y' and `approved` = 'Y' ORDER BY `title`";$result = mysql_query($query,$dbh) or die(mysql_error());} elseif($_GET['site'] == 'opt3') {$query = "SELECT * FROM `links` WHERE `opt3` = 'Y' and `approved` = 'Y' ORDER BY `title`";$result = mysql_query($query,$dbh) or die(mysql_error());}[/code]Still not working....still show all links instead of the selection I want. Thanks above for all the help so far......David Quote Link to comment 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.