Jump to content

sql query problems


franknu

Recommended Posts

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 why

here 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]
Link to comment
https://forums.phpfreaks.com/topic/31370-sql-query-problems/
Share on other sites

i did it with only one and i was still getting  No results found

i have a make, type and categories on the row

this 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 make

please help
Link to comment
https://forums.phpfreaks.com/topic/31370-sql-query-problems/#findComment-145181
Share on other sites

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
Link to comment
https://forums.phpfreaks.com/topic/31370-sql-query-problems/#findComment-145223
Share on other sites

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%\" ";
Link to comment
https://forums.phpfreaks.com/topic/31370-sql-query-problems/#findComment-145251
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.