Jump to content

[SOLVED] 2 queries NOT working?


le007

Recommended Posts

Can anybody pls look and tell me whats wrong with the below? Its just NOT working at all :(

The wrong results keep coming up!

 

if ($prop_type == "%"){
$sql = "SELECT * FROM `cheap_tabl` WHERE (`property_type` like 'Agricultural Land' OR `property_type` like 'Business' OR `property_type` like 'Cafe/Deli' OR `property_type` like 'Commerical Site' OR `property_type` like 'Development Site' OR `property_type` like 'Farm Land' OR `property_type` like 'Franchises' OR `property_type` like 'Garage' OR `property_type` like 'Health and Beauty' OR `property_type` like 'Hotels/B+Bs' OR `property_type` like 'Industrial Unit' OR `property_type` like 'Investment' OR `property_type` like 'Licensed Premises' OR `property_type` like 'New Developments' OR `property_type` like 'Office Share' OR `property_type` like 'Office Unit' OR `property_type` like 'Parking Space' OR `property_type` like 'Public House' OR `property_type` like 'Retail Unit' OR `property_type` like 'Shop' OR `property_type` like 'Supermarket' OR `property_type` like 'Warehouse Unit') and `area` like '$county' and `town_city` like '$town' and `price` > ($minprice + 1) and `price` < ($maxprice + 1) and `bedrooms` > ($minbeds - 1) and `bedrooms` < ($maxbeds + 1) ORDER BY cheap_id DESC LIMIT $from, $max_results";
$sirsql = mysql_query($sql) or die(mysql_error());
} elseif ($prop_type !== "%"){
$sql = "SELECT * FROM `cheap_tabl` WHERE `property_type` like '$prop_type' and `area` like '$county' and `town_city` like '$town' and `price` > ($minprice + 1) and `price` < ($maxprice + 1) and `bedrooms` > ($minbeds - 1) and `bedrooms` < ($maxbeds + 1) ORDER BY cheap_id DESC LIMIT $from, $max_results";
$sirsql = mysql_query($sql) or die(mysql_error());
}


if ($prop_type == "%"){
$total_results = mysql_result(mysql_query("SELECT COUNT(*) as Num FROM `cheap_tabl` WHERE (`property_type` like 'Agricultural Land' OR `property_type` like 'Business' OR `property_type` like 'Cafe/Deli' OR `property_type` like 'Commerical Site' OR `property_type` like 'Development Site' OR `property_type` like 'Farm Land' OR `property_type` like 'Franchises' OR `property_type` like 'Garage' OR `property_type` like 'Health and Beauty' OR `property_type` like 'Hotels/B+Bs' OR `property_type` like 'Industrial Unit' OR `property_type` like 'Investment' OR `property_type` like 'Licensed Premises' OR `property_type` like 'New Developments' OR `property_type` like 'Office Share' OR `property_type` like 'Office Unit' OR `property_type` like 'Parking Space' OR `property_type` like 'Public House' OR `property_type` like 'Retail Unit' OR `property_type` like 'Shops' OR `property_type` like 'Supermarkets' OR `property_type` like 'Warehouse Unit') and `area` like '$county' and `town_city` like '$town' and `price` > ($minprice + 1) and `price` < ($maxprice + 1) and `bedrooms` > ($minbeds - 1) and `bedrooms` < ($maxbeds + 1)"),0);
} elseif ($prop_type !== "%"){
$total_results = mysql_result(mysql_query("SELECT COUNT(*) as Num FROM `cheap_tabl` WHERE `property_type` like '$prop_type' and `area` like '$county' and 
`town_city` like '$town' and `price` > ($minprice + 1) and `price` < ($maxprice + 1) and `bedrooms` > ($minbeds - 1) and `bedrooms` < ($maxbeds + 1)"),0);
}

Link to comment
https://forums.phpfreaks.com/topic/73549-solved-2-queries-not-working/
Share on other sites

WHERE `property_type` in ('Agricultural Land','Business','Cafe/Deli','Commerical Site','Development Site','Farm Land','Franchises', 'Garage','Health and Beauty','Hotels/B+Bs','Industrial Unit','Investment','Licensed Premises','New Developments','Office Share','Office Unit','Parking Space', 'Public House' ,'Retail Unit' ,'Shop','Supermarket','Warehouse Unit')

 

and we use like when we are referring to field which is no exact

eg like '%teng'  <--match any thing that has teng at the end

like '%teng%'  <--match any thing that has teng

and i guess you need this

 

where `property_type` no in ('teng','astig') <-- returns all record asside from teng and astig

teng84 Thank you very very much! You have saved me so much effort - that was really brilliant thinking!

 

IT WORKED!!! YAY!!!!!!!!!!!!!!!  ;D:D :D ;D ;D :D :D ;D ;D :D :D ;)

 

Where in no didnt work for some reason but where in did!!! AWESOME!!!!!!!!!!!!!!!!!!!!!!!!!

 

Thank you again!!!

Leo

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.