franknu Posted December 20, 2006 Share Posted December 20, 2006 ok, i want that when the user select type and make and there is a Categories for type and make to display what is on the database the problem is that i am getting No Results found any idea whyhere is my code[code=php:0]$query = "SELECT * ". "FROM `business_info` ". "WHERE `make`=='make' ". "AND `type`=='type'". ((!empty($Categories)) ? " AND `Categories` LIKE '%".$Categories."%'":''); $result = mysql_query($query) or die (mysql_error()); $num_result = mysql_num_rows($result); echo "<table>";if($num_result <= 0){ echo("No Results found."); exit;[/code] Quote Link to comment Share on other sites More sharing options...
Orio Posted December 20, 2006 Share Posted December 20, 2006 Dont use ==, you only need one =[code]`make`=='make' //wrong`make`='make' //correct[/code]Orio. Quote Link to comment Share on other sites More sharing options...
franknu Posted December 20, 2006 Author Share Posted December 20, 2006 i did it with only one and i was still getting No results found i have a make, type and categories on the rowthis one works[code=php:0]$query = "SELECT * FROM `business_info` WHERE Categories LIKE '%".$Categories."%'";[/code] but it only search for categories it doen't mind what is on type and makeplease help Quote Link to comment Share on other sites More sharing options...
franknu Posted December 20, 2006 Author Share Posted December 20, 2006 [code=php:0]$query = "SELECT * ". "FROM `business_info` ". "WHERE `make`='make' ". "AND `type`='type'". ((!empty($Categories)) ? " AND `Categories` LIKE '%".$Categories."%'":''); [/code] Quote Link to comment Share on other sites More sharing options...
franknu Posted December 20, 2006 Author Share Posted December 20, 2006 thi is are new changes[code=php:0]$query = "SELECT * FROM `business_info` WHERE `make`='make' AND `type`='type'" AND Categories LIKE '%".$Categories."%'";[/code]but this is the error message that i got Parse error: syntax error, unexpected T_STRING in /home/townsfin/public_html/business_display.php on line 45 Quote Link to comment Share on other sites More sharing options...
Round Posted December 20, 2006 Share Posted December 20, 2006 Try this$query = "SELECT * FROM `business_info` WHERE `make`='make' AND `type`='type'" AND Categories LIKE \"%.$Categories.%\" "; Quote Link to comment Share on other sites More sharing options...
franknu Posted December 20, 2006 Author Share Posted December 20, 2006 ok i made new changes and this is the new: code:[code=php:0]$query = "SELECT * FROM `business_info` WHERE `make`='make' AND `type`='type' AND Categories LIKE '%".$Categories."%'";[/code]message, No Results found Quote Link to comment Share on other sites More sharing options...
franknu Posted December 20, 2006 Author Share Posted December 20, 2006 i tried the last code but no luckNo Results found Quote Link to comment Share on other sites More sharing options...
Round Posted December 20, 2006 Share Posted December 20, 2006 You will always have to use the backslashes when using wildcards and or variables$query = "SELECT * FROM `business_info` WHERE `make`='make' AND `type`='type'" AND Categories LIKE \"%$Categories%\" ";Try removing the fullstops Quote Link to comment Share on other sites More sharing options...
franknu Posted December 20, 2006 Author Share Posted December 20, 2006 this is what i tried [code=php:0]$query = "SELECT * FROM `business_info` WHERE `make`='make' AND `type`='type' AND Categories LIKE \"%.$Categories.%\" ";[/code]displayedNo Results foun Quote Link to comment Share on other sites More sharing options...
Round Posted December 20, 2006 Share Posted December 20, 2006 also shouldnt make and type be put into variables???$query = "SELECT * FROM business_info WHERE make=\"$make\" AND type=\"$type\" AND Categories LIKE \"%$Categories%\" "; cos otherwise you are searching for something that has make stored in the make field??unless you want$query = "SELECT make, type FROM business_info WHERE Categories LIKE \"%$Categories%\" "; Quote Link to comment Share on other sites More sharing options...
Round Posted December 20, 2006 Share Posted December 20, 2006 take out the fullstops!!! [color=red].$Categories.[/color] becomes [color=red]$Categories[/color] no fullstops Quote Link to comment 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.