mysql search using for loop from php
<p>i am a beginner. but I'm practicing a lot for few days with php mysql, and I am trying to use for loop to search an exploded string, one by one from mysql server.
Till now I have no results.
I'm giving my codes,</p>

<pre><code>&lt;?php
// Example 1
 $var = @$_GET['s'] ;

$limit=500;


echo "  ";

echo "$var";

echo "  ";

 $trimmed_array = explode(" ", $var);


echo "$trimmed_array[0]"; // piece1

echo "   ";
$count= count($trimmed_array);
echo $count;

for($j=0;$j&lt;$count;$j++)
{
e    cho "$trimmed_array[$j]";;
echo "  ";
}

echo "   ";




for($i=0; $i&lt;$count ; $i++){
                 $query = "select * from book where name like \"%$trimmed_array[$i]%\" order by name";

         $numresults=mysql_query($query);
         $numrows =mysql_num_rows($numresults);

 if ($numrows == 0)
  {
  echo "&lt;h4&gt;Results&lt;/h4&gt;";
  echo "&lt;p&gt;Sorry, your search: &amp;quot;" . $trimmed_array[i] . "&amp;quot; returned zero results&lt;/p&gt;";
  }


  if (empty($s)) {
  $s=0;
  }


  $query .= " limit $s,$limit";
  $result = mysql_query($query) or die("Couldn't execute query");




echo "&lt;p&gt;You searched for: &amp;quot;" . $var . "&amp;quot;&lt;/p&gt;";





echo "Results&lt;br /&gt;&lt;br /&gt;";


$count=1;



  while ($row= mysql_fetch_array($result)) {
  $name = $row["name"];
  $publisher=$row["publisher"];
  $total=$row["total"];
  $issued=$row["issued"];
  $available=$row["available"];
  $category=$row["category"];

  echo "&lt;table border='1'&gt;&lt;tr&gt;&lt;td&gt;$count)&lt;/td&gt;&lt;td&gt;$name&amp;nbsp;&lt;/td&gt;&lt;td&gt;$publisher&amp;nbsp;&lt;/td&gt;&lt;td&gt;$total&amp;nbsp;&lt;/td&gt;&lt;td&gt;$issued&amp;nbsp;&lt;/td&gt;&lt;td&gt;$available&amp;nbsp;&lt;/td&gt;&lt;td&gt;$category&amp;nbsp;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;" ;
  $count++ ;
  }
   }

?&gt;
</code></pre>
