Code: Select all
<?php
$q=$_GET["q"];
include "dbconn.php";
$result = mysql_query ("SELECT id, wanted FROM admin WHERE wanted LIKE '%$q%'")or die(mysql_error());
while ($row = mysql_fetch_object($result))
{
$string = $row->wanted;
$token = strtok($string,"|");
while($token)
{
if (preg_match("/$token/i", "$q")) { echo "<a href='#' style='text-decoration: none' title='$token'>$token</a><br/>";
$token = strtok("|");
}}
} mysql_free_result($result);
mysql_close($sqlconn);
?>I am passing through "shred" for example, and if in the wanted field, it finds "shreddy|fred|sunny", it should then find that string, and then check that each $token is similar to what I have passed thru on $q.
But it won't. Can anyone see a problem with it?