Jump to content


Photo

min/max search results


  • Please log in to reply
7 replies to this topic

#1 Ninjakreborn

Ninjakreborn
  • Members
  • PipPipPip
  • Information Technology Specialist
  • 3,922 posts
  • Age:33

Posted 22 September 2006 - 03:38 PM

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.????

------

Business Website: http://www.infotechnologist.biz

Personal Website: http://www.joyelpuryear.com

Blog Site: http://www.realmofwriting.com
Services: Web development, application development, mobile development, and custom development. All services listed on my website.


#2 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 22 September 2006 - 03:52 PM

somethink like this i say but only a guess.

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

Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#3 Ninjakreborn

Ninjakreborn
  • Members
  • PipPipPip
  • Information Technology Specialist
  • 3,922 posts
  • Age:33

Posted 22 September 2006 - 04:51 PM

$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.

------

Business Website: http://www.infotechnologist.biz

Personal Website: http://www.joyelpuryear.com

Blog Site: http://www.realmofwriting.com
Services: Web development, application development, mobile development, and custom development. All services listed on my website.


#4 Barand

Barand
  • Moderators
  • Sen . ( ile || sei )
  • 18,021 posts

Posted 22 September 2006 - 05:57 PM

What column type is the number column? If it is char or varchar, change it to a numeric type such as INT
If you are still using mysql_ functions, STOP! Use mysqli_ or PDO. The longer you leave it the more you will have to rewrite.

Donations gratefully received






moon.png

|baaGrid| easy data tables - and more
|baaChart| easy line, column and pie charts

#5 imartin

imartin
  • Members
  • PipPip
  • Member
  • 13 posts

Posted 22 September 2006 - 06:02 PM

What column type is the number column? If it is char or varchar, change it to a numeric type such as INT

If the colum is for prices, then INT type may not be a good idea, as there might be decimal points in the values.

#6 Barand

Barand
  • Moderators
  • Sen . ( ile || sei )
  • 18,021 posts

Posted 22 September 2006 - 06:05 PM

True, I was just going by his example data
If you are still using mysql_ functions, STOP! Use mysqli_ or PDO. The longer you leave it the more you will have to rewrite.

Donations gratefully received






moon.png

|baaGrid| easy data tables - and more
|baaChart| easy line, column and pie charts

#7 shocker-z

shocker-z
  • Members
  • PipPipPip
  • Advanced Member
  • 864 posts
  • LocationNottingham

Posted 22 September 2006 - 06:11 PM

$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
www: www.ukchat.ws | irc: irc.ukchat.ws chan: #blufudge

#8 Ninjakreborn

Ninjakreborn
  • Members
  • PipPipPip
  • Information Technology Specialist
  • 3,922 posts
  • Age:33

Posted 22 September 2006 - 06:30 PM

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.

------

Business Website: http://www.infotechnologist.biz

Personal Website: http://www.joyelpuryear.com

Blog Site: http://www.realmofwriting.com
Services: Web development, application development, mobile development, and custom development. All services listed on my website.





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users