Reply to Re: Connecting to mysql with php

Your name:

Reply:


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-

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация