$sql="    ....   name like '%".$name."%' ";
----- Original Message -----
From: "r.gelstharp" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Saturday, May 05, 2001 2:00 AM
Subject: [PHP-WIN] trouble with MySQL 'LIKE' command


> I'm trying to implement a search on my site. When the user enters a search
> string and pressed the Search button it sends the search string into a
> cariable I call searchfor, and I then construct a query that goes
something
> like :
>
> "SELECT <whatever> FROM <a table> WHERE product_name LIKE $searchfor.....
>
> now I know there are things you can do with LIKE such as '%' to search for
> an arbitrary number of characters before or after the search string.
>
> 'WHERE product_name LIKE '%$searchfor%'....'
>
> this has been causing me problems by outputting mostly rubbish, and then I
> find out that the '$' is used in the LIKE command for matching characters
> too.
>
> How do I construct a SELECT statement that uses a PHP variable in the LIKE
> clause?
>
>
>
> --
> PHP Windows Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]
>
>

-- 
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to