techker Posted September 24, 2013 Share Posted September 24, 2013 Hey guys im going nuts here..i have a car dealership script to do for my budy and i want to do a multiple search for by make.. so i got a litle test script im doing to figure out the results.. $search_string = "'" . implode( "','", $search ) . "'" ;$q3 = "select * from `cars` where Make in ('$search_string') ORDER BY `Make` ASC LIMIT 0 , 30 ";$result = mysql_query($q3); while($info = mysql_fetch_array($result)){ echo $info['Make']; }echo "select * from `cars` where Make in ({$search_string} ) was selected!\n"; So the odd think is i cant get an echo results of it.. so i echo a txt base line to see what the query is. i get (selected Acura and BMW) select * from `cars` where Make in ('Acura','BMW' ) was selected! So if i paste in phpmyadmin select * from `cars` where Make in ('Acura','BMW' ) works perfect.. so why does it not echo?(i just put Make to test for now) thx Quote Link to comment https://forums.phpfreaks.com/topic/282397-search-from-checkbox/ Share on other sites More sharing options...
Solution Barand Posted September 24, 2013 Solution Share Posted September 24, 2013 try in ($search_string) without the single quotes ($searchstring already has quotes) Quote Link to comment https://forums.phpfreaks.com/topic/282397-search-from-checkbox/#findComment-1450996 Share on other sites More sharing options...
techker Posted September 24, 2013 Author Share Posted September 24, 2013 im must of been tired..lol seems to work..thx Quote Link to comment https://forums.phpfreaks.com/topic/282397-search-from-checkbox/#findComment-1451002 Share on other sites More sharing options...
techker Posted September 24, 2013 Author Share Posted September 24, 2013 would you now how to search in database like price under 5000 over 5000? but the issue is is that the column Retail_Price hase the numbers like 5,000 it has that (,) so when i try <= 5,000 i get a mysql error.. Quote Link to comment https://forums.phpfreaks.com/topic/282397-search-from-checkbox/#findComment-1451116 Share on other sites More sharing options...
DavidAM Posted September 24, 2013 Share Posted September 24, 2013 Retail_Price should be a NUMERIC column (not VARCHAR), so it will not have the comma in it. Then you can use Retail_Price <= 5000. Using a string-type field for numeric data will make it virtually impossible to compare: i.e. 120 < 30 when compared as a string. Quote Link to comment https://forums.phpfreaks.com/topic/282397-search-from-checkbox/#findComment-1451122 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.