$words = explode(" ",$keywords);
foreach($words as $word) {
Create your sql.
}
.. or $words[0] = 'first word', $words[1]='second word'
That will do what you asked, though I suspect you'll be back when you
want to add quoted phrases, such that you could have $q = green eggs
"and ham" ... then retaining 'and ham' as a token by itself.
At that point you'll probably want to delve into a regex to solve the
problem.
On Thu, Mar 07, 2002 at 10:08:00AM +1300, Philip J. Newman wrote:
> heres my example:
>
> I want to break up the search words in a string.
>
> eg: $q = green eggs
>
> would like that to be
>
> $q1 = green
> $q2 = eggs
>
> ... then ....
>
> the mysql process
>
> $sql = "";
>
> for ($i = 0; $i < $num; $i++)
> if (strlen($getme_arr[$i]) > 0)
> $sql .= " '%".$getme_arr[$i]."%'";
>
> $sql .= " ORDER BY `id` ASC LIMIT 0, 30";
>
> ... This should send to my sql ...
>
> SELECT * FROM `hyperlinks` WHERE 1 AND `keywords` LIKE "green" AND `keywords` LIKE
>"eggs" ORDER BY `id` ASC LIMIT 0, 30
>
> How ever it really down't want to work. Any Suggestions
>
> Philip J. Newman
> PhilipNZ :: Design Solutions
> http://www.philipnz.com/
> [EMAIL PROTECTED]
> ICQ# 20482482
> +64 25 6144012
--
Hank Marquardt <[EMAIL PROTECTED]>
http://web.yerpso.net
GPG Id: 2BB5E60C
Fingerprint: D807 61BC FD18 370A AC1D 3EDF 2BF9 8A2D 2BB5 E60C
*** Web Development: PHP, MySQL/PgSQL - Network Admin: Debian/FreeBSD
*** PHP Instructor - Intnl. Webmasters Assn./HTML Writers Guild
*** Beginning PHP && PHP II -- Starting March 25, 2002
*** See http://www.hwg.org/services/classes
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php