businessman332211@hotmail.com Posted September 22, 2006 Share Posted September 22, 2006 $select = "SELECT * FROM $postset WHERE categoryname = '$category' AND subcategoryname = '$subcategory' AND schoolname = '$school' AND (price BETWEEN '$searchpricemin' AND '$searchpricemax');"; $select = "SELECT * FROM $postset WHERE categoryname = '$category' AND subcategoryname = '$subcategory' AND schoolname = '$school' AND price > '$searchpricemin' AND price < '$searchpricemax';"; can someone please help, I have to get this project finished today but thanks to this I won't. I don't thinkit's not searching properly, if the number is like 80, and my min is 70 and max is 95 it returns it, but if I go too high or low from the numbers it doesn't likeminimum- 50maximum- 200then it doesn't return it, what's going on. It's to search the price between a specific range. Link to comment Share on other sites More sharing options...
aspnetguy Posted September 22, 2006 Share Posted September 22, 2006 remove the brackets on the first query and it should work. Link to comment Share on other sites More sharing options...
businessman332211@hotmail.com Posted September 22, 2006 Author Share Posted September 22, 2006 still didn't work, the one in there for testing is 80, even if I go show much as a little off on min/max it's not reading itminimum 50 maximum 100it doesn't read it because hte minimum is 50, what's going on.This is what I am using now.$select = "SELECT * FROM $postset WHERE categoryname = '$category' AND subcategoryname = '$subcategory' AND schoolname = '$school' AND price BETWEEN '$searchpricemin' AND '$searchpricemax';"; Link to comment Share on other sites More sharing options...
aspnetguy Posted September 22, 2006 Share Posted September 22, 2006 what database are you using? MySql? is ...AND '$searchpricemax';"; really necessary? try this ...AND '$searchpricemax'"; I doubt MySql requires the ; after the sql statement.The time I have seen that needed is working ont he command line Link to comment Share on other sites More sharing options...
businessman332211@hotmail.com Posted September 22, 2006 Author Share Posted September 22, 2006 I tried taking that out but it's still not working, I am using mysql, i can't believe this, thanks to this I won't get the bonus for finishing it today, this is really aggravating, I thought I was using it like it was suppose to be used.Even when I blatantly told it, return search results were price was greater than the minimum, but less than the maximum, it still didn't work, I really don't understand this. Link to comment Share on other sites More sharing options...
aspnetguy Posted September 22, 2006 Share Posted September 22, 2006 hahaha I think I see the problemprice BETWEEN '$searchpricemin' AND '$searchpricemax'";do this instead price BETWEEN $searchpricemin AND $searchpricemax"; You are telling the query that your numbers are strings so it is doing an alphabetical search80 = 'eighty' 50 = 'fifty'in this case 50 comes after 80 Link to comment Share on other sites More sharing options...
businessman332211@hotmail.com Posted September 22, 2006 Author Share Posted September 22, 2006 Actually I just now noticed that, but the fix was me changing the data type to int, I had it as varchar in the database, but now I have it as the number, but I think either solutions would have worked, I just wish I had of known that before. Link to comment Share on other sites More sharing options...
aspnetguy Posted September 22, 2006 Share Posted September 22, 2006 actually it probably required both parts to make it work correctly. Glad to hear it is working. Link to comment Share on other sites More sharing options...
justsomeguy Posted September 25, 2006 Share Posted September 25, 2006 what database are you using? MySql? is ...AND '$searchpricemax';"; really necessary? try this ...AND '$searchpricemax'"; I doubt MySql requires the ; after the sql statement.The time I have seen that needed is working ont he command lineThere seems to be a little confusion with regard to this, and since I just noticed this myself, from http://www.php.net/manual/en/function.mysql-query.php :The query string should not end with a semicolon. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now