Jump to content


Photo

operators


  • Please log in to reply
5 replies to this topic

#1 Brendan

Brendan
  • Members
  • PipPip
  • Member
  • 26 posts

Posted 13 August 2006 - 08:00 PM

How would i go about searching a mysql database for a value greater than one number and less than or equal to another, and visa versa?

For Example
if ($price=="3") {$op.="(price>61.00 && price<=100.99)";}    

This doesnt work of course, but perhaps it will give an idea of what im trying to achieve.

Thanks,
-Brendan




#2 Barand

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

Posted 13 August 2006 - 09:47 PM

$p1 = 61.00;
$p2 = 100.99;

... WHERE price > $p1 AND price <= $p2

or

$p1 = 61.01;
$p2 = 100.99;

... WHERE price BETWEEN $p1 AND $p2
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

#3 Brendan

Brendan
  • Members
  • PipPip
  • Member
  • 26 posts

Posted 01 September 2006 - 11:03 PM

where category='1' AND price>'61.00' AND price<='100.99' ORDER BY prod DESC

I've tried that, but this doesn't seem to work.

#4 trq

trq
  • Staff Alumni
  • Advanced Member
  • 31,041 posts

Posted 01 September 2006 - 11:14 PM

What field types are you using?

#5 Barand

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

Posted 01 September 2006 - 11:15 PM

Define doesn't work.

Query gives an error or you don't get the results you expect?
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

#6 Caesar

Caesar
  • Members
  • PipPipPip
  • Advanced Member
  • 1,025 posts

Posted 01 September 2006 - 11:24 PM

What field types are you using?


PHP Ninja




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users