I'm trying to match users with a certain description in one table to a general search description in another table. I have a foreach that contains the general descriptions and created a query within the foreach hoping to pull out the user that best fits that general description.
Problem is I'm not getting any results when I echo out the username. I get results when I echo out result['title'].
if (empty($errors)){
$results = search_results($keywords);
$results_num = count($results);
echo '<p><strong style ="font-size:145%;font-family:georgia;"> Titles: </strong></p> ';
foreach ($results as $result){
$query = mysql_query("SELECT username, title from clothing
WHERE description LIKE '%$results%'");
while($row=mysql_fetch_array($query)){
$username=$row['username'];
$title=$row['title'];
echo $username;
}
echo '<p> <strong>',$result['title'],'</strong> </p>';
}
}
I would be very grateful to know why my user is not getting echoed out. Also any programming tips would be greatly appreciated for I am always learning and I want to always find ways to improve.
foreachvariable$result, not$resultsas you have:LIKE '%$results%'"