I am making a search script that searches for employees based on certain criteria. You can see the page here: http://www.conceptxsolutions.com/testsearch.htm . It is a PHP file that queries a MySQL database for the desired search term. I would like to attach a photo of each employee that is pulled up and placed beside their name when searched for. I do not want to actually store the images in the database. I just want to store the name of the picture in the same row as the employee. The picture itself will be stored in the directory with the PHP script. That way when the query is executed, it just brings the name of the picture. Then I was hoping that using <img src=""> tag I could display it. Does that make sense? Here is the code I tried to use (it is embedded in an HTML page):
<?php
//Create Short Variable Names
$searchtype = $HTTP_POST_VARS['searchtype'];
$searchterm = $HTTP_POST_VARS['searchterm'];
$searchterm = trim($searchterm);
if(!$searchtype || !$searchterm)
{
echo 'You have not entered the search details. Please go back and try again.';
exit;
}
$searchtype = addslashes($searchtype);
$searchterm = addslashes($searchterm);
@ $db = mysql_pconnect('localhost', '*****', '*****');
if (!$db)
{
echo 'Error: Could not connect to database. Please try again later.';
exit;
}
mysql_select_db('conceptx');
$query = "select * from employee where ".$searchtype." like '%".$searchterm."%'";
$result = mysql_query($query);
$num_results = mysql_num_rows($result);
echo '<p>Number of Results Found: '.$num_results.'</p>';
for ($i=0; $i < $num_results; $i++)
{
$row = mysql_fetch_array($result);
echo '<p><strong>' .($i+1).'. First Name: ';
echo htmlspecialchars (stripslashes ($row['first_name']));
echo '</strong><br /> Last Name: ';
echo stripslashes ($row['last_name']);
echo '<br /> Location: ';
echo stripslashes ($row['location']);
echo '<br /> Grant: ';
echo stripslashes ($row['money']);
echo '</p>';
print "<img src="$row['image']">";
}
?>