Jump to content

Use two "BETWEEN" in one query


Recommended Posts

Hello,I want to enable the user to search by both price and area in the same time by entering price and area rangesuntil now I can search any of those two using "between" but I can not use 2 "between" in one queryIs that possible?If it is not What is the alternative?Thank you in advance

Link to post
Share on other sites

You might need to add parens for clarity.

$result = mysql_query("SELECT * FROM price WHERE (price BETWEEN $price1 AND $price2) AND (area BETWEEN $area1 AND $area2)") or die(mysql_error());

There might also be an issue because you named a field the same thing as the table.

Link to post
Share on other sites

I found what was the problem, it was not the syntax of the query or the name of the table the whole problem was that I wrote$area2 = floatval($_post['area2'];instead of:$area2 = floatval($_POST['area2'];thank you very much for your help justsomeguy, You are the BEST!!!.

Link to post
Share on other sites

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.   Paste as plain text instead

  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.

Loading...
×
×
  • Create New...