kamal213 Posted October 12, 2011 Share Posted October 12, 2011 Hi guys, I have this SQL query which I use in my PHP search script $query_for_result=mysql_query("SELECT * FROM customer WHERE c_name like '%".$query."%' OR c_telephone like '%".$query."%' OR c_address like '%".$query."%'"); It works fine, the only problem is now my database is bigger I would like to be able do SORT or ORDER BY id so that my search results are in order from asc to desc. Is this possible? if so can you help me. Thanks Quote Link to comment https://forums.phpfreaks.com/topic/248967-re-sql-sortorder-search-results/ Share on other sites More sharing options...
WebStyles Posted October 12, 2011 Share Posted October 12, 2011 you said it man: ORDER BY id is it not working for some reason? Quote Link to comment https://forums.phpfreaks.com/topic/248967-re-sql-sortorder-search-results/#findComment-1278569 Share on other sites More sharing options...
kamal213 Posted October 12, 2011 Author Share Posted October 12, 2011 Thanks webSyles It works now!!!!! I was doing: $query_for_result=mysql_query("SELECT * FROM customer ORDER BY id WHERE c_name like '%".$query."%' OR c_telephone like '%".$query."%' OR c_address like '%".$query."%'"); Instead of $query_for_result=mysql_query("SELECT * FROM customer WHERE c_name like '%".$query."%' OR c_telephone like '%".$query."%' OR c_address like '%".$query."%' ORDER BY id "); MY MISTAKE thanks for you help webstyle!! Problem SOLVED! Quote Link to comment https://forums.phpfreaks.com/topic/248967-re-sql-sortorder-search-results/#findComment-1278572 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.