Re: spliting keywords by GET method and SQL query

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



$whereStatement=str_replace("+", " AND message LIKE ", $strToParse);
$whereStatement=str_replace(",", " OR message LIKE ", $whereStatement);

SELECT * FROM mytable WHERE message LIKE $whereStatement

As for your invalid input example, good luck, I don't see any easy way
of doing that.


On Wed, 29 Sep 2004 18:47:28 +0300, Murat BIYIKLI
<admin@xxxxxxxxxxxxxxxxxxxx> wrote:
> I need to split the keyword on search input and generate an sql query,
> for ex:   the input value is:   europe+america,asia
> so I want to generate an sql like this:
> SELECT * FROM mytable WHERE message LIKE %europe% AND message LIKE %america%
> OR message LIKE %asia%
> 
> The + (plus) means AND and , (comma) means OR. Also I need to control input
> variables to prevent error on sql query forexample an input value like:
> ,,,europe+america,+asia+    should not generate an error.
> 
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
>

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux