So im making a search form, where you type in some words and it brings you to a page where it lists all your results, I use a loop that goes through every word and for now im just trying to check the occurance of each individual word through all the strings that fit into "WHERE description LIKE '%$word%'"
So I got a simple version to work but now im trying to check the number of times each word appears (as described) but the problem im having is that It will only check the first word's number of occurances.
here is the script
PHP Code:
//variables
$search=$_GET['term'];
$search_words=explode(' ', $search);
$search_list = array();
//looping
foreach ($search_words as $word) {
$query = mysql_query("SELECT * FROM search WHERE description LIKE '%$word%'");
echo $word;
while ($row = mysql_fetch_array($query))
{
$string=$row['description'];
$subs = substr_count($string, $word);
echo "row 1: " . $subs . "<br>";
echo $string;
echo $word;
echo "<p>";
}
please help thanks