Jump to content

Archived

This topic is now archived and is closed to further replies.

Ninjakreborn

min/max search results

Recommended Posts

I have a table called price
inside there, it's going to say a number
just a regular number
then for minimum maximum price the person can put
30 70
which 30 is minimum 70 is maximum
this is going to search in the database, for all the results within that range.????

Share this post


Link to post
Share on other sites
somethink like this i say but only a guess.

[code]
$query="select price from table where like num='%".$num."%' and price > 30  or < 70 ";
$result=mysql_query($query);
[/code]

Share this post


Link to post
Share on other sites
$select = "SELECT * FROM $postset WHERE categoryname = '$category' AND subcategoryname = '$subcategory' AND schoolname = '$school' AND price > '$searchpricemin' AND price < '$searchpricemax';";
ok this was the search query, I have one in the db, with price of 80 just for a test
When I put in minimum of 70 maximum of 85 or 90 then it works
but when I put in, minimum of 70 maximum of 100 or higher, it doesn't bring search results, I need it to get everything within that minimum maximum range, what's going on.

EDIT
see I also just tried usin
$select = "SELECT * FROM $postset WHERE categoryname = '$category' AND subcategoryname = '$subcategory' AND schoolname = '$school' AND price BETWEEN '$searchpricemin' AND '$searchpricemax';"
and it's not working right.  The min number and max numbers are also recieving the right values, it's just neither one seem to be working.

Share this post


Link to post
Share on other sites
What column type is the number column? If it is char or varchar, change it to a numeric type such as INT

Share this post


Link to post
Share on other sites
[quote author=Barand link=topic=109078.msg439550#msg439550 date=1158947873]
What column type is the number column? If it is char or varchar, change it to a numeric type such as INT
[/quote]
If the colum is for prices, then INT type may not be a good idea, as there might be decimal points in the values.

Share this post


Link to post
Share on other sites
$select = "SELECT * FROM $postset WHERE categoryname = '$category' AND subcategoryname = '$subcategory' AND schoolname = '$school' AND price BETWEEN $searchpricemin AND $searchpricemax";

but as said above if it is not 'int' in table then wont work.. also not sure if as they are int being checked if it needs to be surounded with '' or not

Share this post


Link to post
Share on other sites
yes after fighting with it for like 3-5 hours I realized I needed it set to int, it was a big waste of time over something that wouldn't have happened, if I had of known that, I just didn't think about it having anything to do with db types, until at the end.

Share this post


Link to post
Share on other sites

×

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.