npsari Posted April 7, 2007 Share Posted April 7, 2007 I have a comboBox called Countries I want if a user selects 'All countries' he gets all results from the database I usedthis code, and it worked... mysql_select_db(database); $Countries = $_POST['Coutries']; $q = "SELECT * from table"; if ($Countries!="All countries") { $q.= " WHERE Countries = '$Countries'"; } $q.= " ORDER by Date DESC LIMIT 100";} But I have a second combobox which is Town I want if the user selects all towns, he also gets all results I did this, but it doesnt work mysql_select_db(database); $Countries = $_POST['Coutries']; $q = "SELECT * from table"; if ($Countries!="All countries") { $q.= " WHERE Countries = '$Countries'"; } $Town = $_POST['Town']; $q = "SELECT * from table"; if ($Town!="All Towns") { $q.= " WHERE Town = '$Town'"; } $q.= " ORDER by Date DESC LIMIT 100"; How can I make it work Link to comment https://forums.phpfreaks.com/topic/45995-show-all-results-from-mysql-database/ Share on other sites More sharing options...
metrostars Posted April 7, 2007 Share Posted April 7, 2007 You could make $town = % (mysql wildcard) if $_POST['town'] == Alltowns. Link to comment https://forums.phpfreaks.com/topic/45995-show-all-results-from-mysql-database/#findComment-223512 Share on other sites More sharing options...
npsari Posted April 7, 2007 Author Share Posted April 7, 2007 You mean like this... mysql_select_db(database); $Countries = $_POST['Coutries']; $q = "SELECT * from table"; if ($Countries!="All countries") { $q.= " WHERE Countries = '$Countries'"; } $town = % (mysql wildcard) if $_POST['town'] == Alltowns. $q.= " ORDER by Date DESC LIMIT 100"; Can you please show me where do I put your part to my code Link to comment https://forums.phpfreaks.com/topic/45995-show-all-results-from-mysql-database/#findComment-223518 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.