Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.