surfsup Posted November 21, 2008 Share Posted November 21, 2008 Newbie so bare with me. trying to filter a recordset with 2 variables submitted from a form. i.e. If user selects dropdown the results will be filtered by that value alone. If user selects value from both results filtered by both values This works fine for one <?php $colname_rs_Results = "%"; if (isset($_GET['v_sleeps'])) { $colname_rs_Results = $_GET['v_sleeps']; } $colname2_rs_Results = "%"; if (isset($_GET['v_location'])) { $colname2_rs_Results = $_GET['v_location']; }?> <?php mysql_select_db($database_FireFly, $FireFly); $result = mysql_query("SELECT * FROM ff_villas WHERE v_sleeps = $colname_rs_Results"); while($row = mysql_fetch_array($result)) { echo $row['v_name'] ; echo "<br />"; } ?> but this gives me errors <?php $colname_rs_Results = "%"; if (isset($_GET['v_sleeps'])) { $colname_rs_Results = $_GET['v_sleeps']; } $colname2_rs_Results = "%"; if (isset($_GET['v_location'])) { $colname2_rs_Results = $_GET['v_location']; }?> <?php mysql_select_db($database_FireFly, $FireFly); $result = mysql_query("SELECT * FROM ff_villas WHERE v_sleeps = $colname_rs_Results AND v_country = $colname_rs_Results"); while($row = mysql_fetch_array($result)) { echo $row['v_name'] ; echo "<br />"; } ?> I hope that makes sense if not the greates tbit of coding ever seen Link to comment https://forums.phpfreaks.com/topic/133667-filtering-with-multiple-variables/ Share on other sites More sharing options...
xangelo Posted November 21, 2008 Share Posted November 21, 2008 Not sure but would the colname_rs_results actually be colname2_rs_results? If so, your script would be slightly modified to the following: $result = mysql_query("SELECT * FROM ff_villas WHERE v_sleeps = $colname_rs_Results AND v_country = $colname2_rs_Results"); If not, what is the exact error that you are getting? Link to comment https://forums.phpfreaks.com/topic/133667-filtering-with-multiple-variables/#findComment-695550 Share on other sites More sharing options...
surfsup Posted November 24, 2008 Author Share Posted November 24, 2008 Yes you are correct. I switeched that but still get this error Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in D:\home\Default\fireflylodges.com\htdocs\property.php on line 17 line 17 being while($row = mysql_fetch_array($result)) Link to comment https://forums.phpfreaks.com/topic/133667-filtering-with-multiple-variables/#findComment-697606 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.