Page 1 of 1

How can I attach % to a $variable in a query_string?

Posted: Fri Mar 19, 2004 1:43 pm
by johncal
Hello All,
Thanks in advance for reading this.

I am trying to use 'like' in a query_string for mysql,
but can't seem to incorporate the % properly.

For example, the actual sql is:
SELECT * FROM table WHERE date like '1999%'
(Needless to say it brings back all entries for 1999)

So, I need to construct a query string out of this, however the date
(which is formated in the table as yyyy-mm-dd) is a variable

for example:
$query_string = "SELECT * FROM table WHERE date like '$date'

HOW do I attach the % to the variable $date in this string?

thanks !

John[/b]

Posted: Fri Mar 19, 2004 2:09 pm
by Illusionist
$date%

have u tried that??

Posted: Fri Mar 19, 2004 3:00 pm
by penguinboy

Code: Select all

$query_string = "SELECT * FROM table WHERE date LIKE '".$date."%'"