I am trying to do part of a Mysql search
.. so the price from DB is less than the MAX, but greater than MIN chosen
How do i do this?
.. AND price = < '%$max% > '%$min%'; [code=php]
AND price<'$max' AND price>'$min';
tis not working
$db = mysql_connect($db_host,$db_user,$db_pass); mysql_select_db ($db_name) or die ("Cannot connect to database"); $query = "SELECT * FROM clients WHERE town LIKE '%$location%' AND style LIKE '%$ptype%' AND country LIKE '%$counrty%' AND rooms LIKE '%$rooms%' AND price<'%$maxprice%' AND price>'%$minprice%'"; $result = mysql_query($query)or die (mysql_error());
Firstly, do you understand the reason for placing the percentage symbol '%' in SQL queries?
from the search boxes on the previous page
Read SQL Command, Type, and Function Index
In particular, the string wildcard character
$db = mysql_connect($db_host,$db_user,$db_pass); mysql_select_db ($db_name) or die ("Cannot connect to database"); $query = "SELECT * FROM clients WHERE town LIKE '%$location%' AND style LIKE '%$ptype%' AND country LIKE '%$counrty%' AND rooms LIKE '%$rooms%' AND price<'".$maxprice."' AND price>'".$minprice."'"; $result = mysql_query($query)or die (mysql_error());
Should work...
no,
typing
macclesfield houses 3 rooms £40,000 £300,000 England
it should bring back some results but its not
Look at the spelling of country.....
£40,000 £300,000
What exactly are your min and max values? They should be numeric.
It looks like your approach is wrong to begin with.
ahh
if i take out the price bit i can get the results, but putting the price in its not working properly, jsut gives nothing found
AND price<'".$maxprice."' AND price>'".$minprice."'
See above at Laserlights...
Are your numerical figures complete numbers,, eg 30000 NOT £30,000
Originally posted by laserlight What exactly are your min and max values? They should be numeric. It looks like your approach is wrong to begin with.
think you got it there.
am using £xxxx.xxxxx formats
Then that approach will not work.
You can change it to a decimal if you want... or as an int - but you can't doa greater or less than on a varchar...
thats it working now
yay 😃 cheers laserlight, and The Chancer