variable operators in queries
| From: | Sander Peters | Date: | Fri, 19 Oct 2001 22:21:38 +0000 |
| Subject: | variable operators in queries | ||
| Groups: | php.db php.general | ||
| Request: | Send a blank email to php-db+get-13550@lists.php.net to get a copy of this message | ||
Hello,
Is it possible to put variable operators in queries?
I tried this (the real variable comes from a form)
$Date_Operator =(">=");
sql="SELECT * FROM poeple WHERE age $Date_operator 20";
$result_id = mysql_query($sql);
It doesn't work like this. I also tried:
sql="SELECT * FROM poeple WHERE age \"$Date_operator\" 20"
$result_id = mysql_query($sql);
it didn't work either.
Or should I use a have to make a IF-Then construction?
If $Date_Operator == (">=")
then
{
sql="SELECT * FROM poeple WHERE age >= 20"
}
etc...
Can anybody help me with this?
Thanks in advance!
--
Met vriendelijke groet / With Greetings,
Sander Peters
site: http://www.visionnet.nl/
email: mailto:s.peters@visionnet.nl
webmail: mailto:sanderpeters@yahoo.com