ricscott Posted February 23, 2007 Share Posted February 23, 2007 Hi everyone, I've been trying to get to grips with this script for a while now and, TBH I'm going bald now over it... It's probably something really basic that's going wrong or, I've totally screwed the script.. I've got 4 <option> boxes with choices in... eg: <select name="items" class="seach-box" id="items"> <option value="#">Please Choose</option> <option value="0">Any</option> <option value="1">Item1</option> <option value="2">Item2</option> </select> etc...Then the submit... <input name="search" type="submit" class="search-button" id="search" value="Find" /> etc.. Then on the php side... $type=$_GET[type]; $price=$_GET[price]; // link to data $link_id = mysql_connect("local","user","pass"); if (mysql_select_db("db", $link_id)); else die ("connection failed.") ; // Determine where in the database to start returning results. if (isset($_GET['s'])) { $start = $_GET['s']; } else { $start = 0; } $flag = 0; $query_search=""; if($type=="Any") if($type !=="0")// if search is NOT for all a bit more needs to be added { if($type=="1") { $prop_type="item1"; } if($type=="2") { $prop_type="item2"; } if($type=="3") { $prop_type="item3"; } if($type=="4") { $prop_type="item4"; } // And so on $query_search.= " WHERE type = '$prop_type' "; } if($price !=="0") { if($price=="1") { $range=" < 100000 "; } if($price=="2") { $range=" BETWEEN 100000 and 200000"; } if($price=="3") { $range=" BETWEEN 200000 and 400000"; } if($price=="4") { $range=" 400000 >"; } //And So On { $query_search.= " AND price = '$range' "; }else{ $query_search.= " WHERE price = '$range' "; } } $sql="SELECT ID, and everything else etc FROM tbl $query_search"; $result = @mysql_query ($sql); Pls help...this is now becomming urgent...I'm using MySQL 5.0.27 and PHP 5.2.0 is there another way?? Link to comment https://forums.phpfreaks.com/topic/39852-solved-help-with-multiple-combo-box-filtering-script/ Share on other sites More sharing options...
paul2463 Posted February 23, 2007 Share Posted February 23, 2007 first fault <?php // your first two lines $type=$_GET[type]; $price=$_GET[price]; //should read $type=$_GET['type']; $price=$_GET['price']; // we will assume that they are being set properly //second error change this line $result = @mysql_query ($sql); // the @ sysmbol stops errors being shown //for this $result = mysql_query($sql) or die('Invalid query: ' . mysql_error()); ?> and find out if there is a fault with the building of your query Link to comment https://forums.phpfreaks.com/topic/39852-solved-help-with-multiple-combo-box-filtering-script/#findComment-192516 Share on other sites More sharing options...
ricscott Posted February 23, 2007 Author Share Posted February 23, 2007 Thanks for the reply.. I tried what you suggested and just got a blank screen if I choose an option, however, before, I failed to mention, if I just choose, 'Any' from both boxes I get a result...all the items from the db, but now, just a blank screen... Link to comment https://forums.phpfreaks.com/topic/39852-solved-help-with-multiple-combo-box-filtering-script/#findComment-192536 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.