Posted by David Haynes on 02/14/06 18:57
Dave Mennenoh wrote:
>>> $query = select * from books where ".$searchtype." like
>>> '%".$searchterm."%'" ;
>
> Besides missing the leading quotation mark, you might like to know that you
> don't need to do concatenation like this using PHP - so you can simply do
> this:
>
> $query = select * from books where $searchtype like '%$searchterm%'" ;
>
> weird huh!
>
You also might like to use a format like:
$query = <<<EOQ
SELECT *
FROM books
WHERE {$searchtype} LIKE '%{$searchterm}%'
EOQ;
Which make the whole query a lot clearer to those used to SQL CLI
environments.
-david-
Navigation:
[Reply to this message]
|