The problem is caused by the IF statement. Your SQL query will return every record from the table but the extract() function will only extract the variables from the first record. What you should do instead is find which record you care about, then only get that.
Looking at your code it seems that you haven't thought things through very well.
Check if $_GET["find"] is set using
Code:
if (isset($_GET["find"])) Then get only that record.
Code:
$result = mysql_query("SELECT * from `people` WHERE person = '".mysql_escape_string($_GET["find"])."'"; Then you need error checking to see if that person was found (using
mysql_num_rows() will do the trick).
It's almost easier starting from scratch. Say exactly what you want. Here's what I gathered. You want it so a name can be passwed in the query. If a name is passed you want to find all images in your database related to that person. You then want those images echoed out into a table which has 4 images across and as many rows as are requied. is that right?
For that you only need one table, called `pics`. Get the username, then
SELECT `pic` FROM pics WHERE person='".mysql_escape_string($_GET['find'])."'. That will only return the urls of the images regarding that person. Then loop through that $result (again using mysql_num_rows) and echo the image. OK, that most likely didn't help you much so I'll try and code it myself. Note that this code is totally untested.
Code:
...
<?php
$connection = mysql_connect($host,$user,$password)
or die ("couldn't connect to server");
$db = mysql_select_db($database,$connection)
or die ("Couldn't select database");
echo "<center><table cellpadding='5' border='1'>";
echo "<tr>";
if (isset($_GET['find']))
{
$per_row = 4;
echo "Person: ".htmlentities($_GET['find']);
$result = mysql_query("SELECT pic FROM pics WHERE person='".mysql_escape_string($_GET['find'])."'");
for ($i=0; $i<mysql_num_rows($result); $i++)
{
$pic = mysql_result($result,($i));
echo "<td align='center'><img src='$pic'></td>";
if ($i%$per_row == 0)
{
echo "</tr><tr>";
}
}
}
else
{
echo "<font face='Verdana, Arial, Helvetica, sans-serif' size='2'>Sorry no pics found</font>";
}
echo "</tr><center></table>";
echo "<div align='center'>
<table border='1' bgcolor='#999999'><td><a href='media.php'>
<font color='white' face='Verdana, Arial, Helvetica, sans-serif' size='2'>Back to the Start</font></a></td></table></div>";
?>
</td>
</table>
</body>
</html>