Hi there,
I seem to be having a problem, as my search isn't working. So, this is what I am trying to achieve:
There is a column in a MySQL table that is called "sister_markets" and the user inputs data like this:
BLAH, BLAH1, BLAH2
Now, I want to grab this data and search each word individually (as a string) and find the result from another column in the same table (a partial match, only needs to be matching the start of the word). But for some reason, the search isn't working. It comes up with the results of the first string only, no more.
The example data is : WCLD, WCLD-F, WKDJ-F, WMJW, WAID
This is the PHP code:
<?php
$search=$_REQUEST["sm"];
$pieces = explode(",", $search);
foreach ($pieces as $data)
{
$result = mysql_query("SELECT * FROM websiteadmin_radio WHERE call_letters LIKE '$data%'");
while($r=mysql_fetch_array($result))
{
$title=$r["call_letters"];
echo "$title <br />";
}
}
?>
But this only searches WCLD and none of the other strings. I have attempted doing this
<?php
$search=$_REQUEST["sm"];
$pieces = explode(",", $search);
$result = mysql_query("SELECT * FROM websiteadmin_radio WHERE call_letters LIKE ('$pieces')");
while($r=mysql_fetch_array($result))
{
$title=$r["call_letters"];
echo "$title <br />";
}
?>
But this yields no results.
Any help would be highly appreciated.