Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Having a problem with a site search query

Featured Replies

Hi people. Wondering if you can give me some advice on this piece of code please.

 

It is a simple search facility i'm going to use on a site i've been working on. There are 3 fields, (Location, Price Range and Bedrooms)

 

I pretty much have the code working...apart from the price section, if for example i searched for "random town" between "150,000 and 250,000" with "3 bedrooms" . It seems to only display the results of searching for property in "random town" with "3 bedrooms" . i.e. it is ignoring the price range part.

 

Any help would be much appreciated, thanks in advance!

 

 

<?php  
$proploc= $_POST['location'];
$proploc = strtolower($proploc);
$propprice = $_POST['price'];
$propbeds = $_POST['bedrooms'];	

if ($propprice = 'pr0'){ $a = 0; $b = 9000000; }
elseif ($propprice = 'pr1'){ $a = 0; $b = 150000; }
elseif ($propprice = 'pr2'){ $a = 150000; $b = 250000; }
elseif ($propprice = 'pr3'){ $a = 250000; $b = 350000; }
elseif ($propprice = 'pr4'){ $a = 350000; $b = 9000000; }

if ($proploc == "")
{ $query = "SELECT * FROM properties_text WHERE `prop_price` >= '$a' AND `prop_price` <= '$b' AND `prop_beds` = '$propbeds' ORDER BY `prop_id` DESC LIMIT $cur, $max";
}
else 
{ $query = "SELECT * FROM properties_text WHERE `prop_price` >= '$a' AND `prop_price` <= '$b' AND `prop_beds` = '$propbeds'  AND (LOWER(`prop_street`) LIKE '%$proploc%' OR LOWER(`prop_town`) LIKE '%$proploc%' OR LOWER(`prop_name`) LIKE '%$proploc%' OR LOWER(`prop_postcode`) LIKE '%$proploc%') ORDER BY `prop_id`  DESC LIMIT $cur, $max";
}

?>

  • Author

I got this problem sorted.

 

All by myself for a change :-D

  • Author

Simply, it was one of those mistakes that make you want to shoot yourself in the face.

 

  if ($propprice = 'pr0'){ $a = 0; $b = 9000000; }
elseif ($propprice = 'pr1'){ $a = 0; $b = 150000; }
elseif ($propprice = 'pr2'){ $a = 150000; $b = 250000; }
elseif ($propprice = 'pr3'){ $a = 250000; $b = 350000; }
elseif ($propprice = 'pr4'){ $a = 350000; $b = 9000000; }

 

 

The 'pr0,1,2,3,4' should have been 'ps0,1,2,3,4' and i should also have used double =

 

Solution:

 

if ($propprice == 'ps0'){ $a = 0; $b = 9000000; }
elseif ($propprice == 'ps1'){ $a = 0; $b = 150000; }
elseif ($propprice == 'ps2'){ $a = 150000; $b = 250000; }
elseif ($propprice == 'ps3'){ $a = 250000; $b = 350000; }
elseif ($propprice == 'ps4'){ $a = 350000; $b = 9000000; }

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.