bchandel Posted September 1, 2009 Share Posted September 1, 2009 what will be the correct form of this script to Select * FROM Business WHERE City, or State or Country met criterias entered by visitors as form output. Where do I put necessary " or ' or ; or { etc needed to make it work <?php $db_connect = mysql_connect("xxx.com", "xxx_user", "password"); mysql_select_db("xxx_database", $db_connect) or die( "Unable to select database"); $query = SELECT * FROM Business WHERE 'City' LIKE '%$variable%' or State LIKE '%variable%' or Country Like '%variable'; $result = mysql_query($query); $num=mysql_num_rows($result); ?> Quote Link to comment https://forums.phpfreaks.com/topic/172653-need-help-with-script-thank-you-for-your-help/ Share on other sites More sharing options...
MadTechie Posted September 1, 2009 Share Posted September 1, 2009 $query = "SELECT * FROM Business WHERE `City` LIKE '%$variable%' or State LIKE '%variable%' or Country Like '%variable'"; Quote Link to comment https://forums.phpfreaks.com/topic/172653-need-help-with-script-thank-you-for-your-help/#findComment-910070 Share on other sites More sharing options...
bchandel Posted September 1, 2009 Author Share Posted September 1, 2009 Thank you for your help. I made the corrections. However, when I am submitting form even putting any values for City, State, or Country it is displaying all the records in the database. What do I need to do to limit records display unless some one enter some values? One more thing I want to do is to echo $num records found if query meets search criteria or no records found if query does not meet the criteria. Thank you. Quote Link to comment https://forums.phpfreaks.com/topic/172653-need-help-with-script-thank-you-for-your-help/#findComment-910080 Share on other sites More sharing options...
bchandel Posted September 1, 2009 Author Share Posted September 1, 2009 Need help fixing this script. Thank you! Quote Link to comment https://forums.phpfreaks.com/topic/172653-need-help-with-script-thank-you-for-your-help/#findComment-910257 Share on other sites More sharing options...
MadTechie Posted September 1, 2009 Share Posted September 1, 2009 Your need to post more complete code, Quote Link to comment https://forums.phpfreaks.com/topic/172653-need-help-with-script-thank-you-for-your-help/#findComment-910539 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.