livingwells Posted September 2, 2008 Share Posted September 2, 2008 I am a newbie to PHP and have taken over a website that has a form search field that has never worked. Here is the code from with-in the form on the displayed page: (It actually does display a list of cities which to choose from in the dropdown) The problem is, once a city is selected and you click the "submit" button, the results show the entire tbl_listing, not just entries from the selected city. !-- BEGIN: city_select --> <SELECT id="city" name="city" style="width:170px"> <OPTION value="0" selected>Select City/Town</OPTION> <!-- BEGIN: city_option --> <OPTION value="{option_city}">{option_city}</OPTION> <!-- END: city_option --> </SELECT> <!-- END: city_select --> Here is the code on the processing page: $strSQL="select DISTINCT(city) as cityy from tbl_listing order by cityy"; $rsCity=mysql_query($strSQL); while($rowCity=mysql_fetch_array($rsCity)){ $xtpl->assign('option_city', $rowCity["cityy"]); $xtpl->parse('main.city_select.city_option'); } Any help or suggestions would be appreciated greatly! Thanks Link to comment https://forums.phpfreaks.com/topic/122392-form-search-problem/ Share on other sites More sharing options...
JonnoTheDev Posted September 2, 2008 Share Posted September 2, 2008 You need to add a WHERE clause to the SQL based on the users selection Link to comment https://forums.phpfreaks.com/topic/122392-form-search-problem/#findComment-631986 Share on other sites More sharing options...
livingwells Posted September 2, 2008 Author Share Posted September 2, 2008 Can you give me an example? Link to comment https://forums.phpfreaks.com/topic/122392-form-search-problem/#findComment-632047 Share on other sites More sharing options...
BlueSkyIS Posted September 2, 2008 Share Posted September 2, 2008 http://www.tutorialspoint.com/mysql/mysql-where-clause.htm Link to comment https://forums.phpfreaks.com/topic/122392-form-search-problem/#findComment-632124 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.