You are overwriting the vars from the outer query by using the same names inside the loop. Just use different names and you'll be ok
<?php
include('menu.php');
require_once('../includes/DbConnector.php');
$connector1 = new DbConnector();
$result1 = $connector1->query('SELECT photoID,photoFileName,title,description FROM photo ORDER BY photoID DESC LIMIT 0,15');
while ($row1 = $connector1->fetchArray($result1)){
echo '<b>';
echo $row1['title'];
echo '</b> - ';
echo '<a href="../';
echo $row1['photoFileName'];
echo '">';
$connector2 = new DbConnector();
$results2 = $connector2->query("SELECT loaded FROM gall WHERE loaded =".$row1['photoFilename']) or die('ERROR: '.mysql_error());
while ($row2 = $connector2->fetchArray($results2)){
$gall = $row2['loaded'];
}
echo 'Preview</a> :: ';
echo '<a href="drop.php?id='.$row1['photoID'].'&gallid='.$gall.'">Drop Photo</a><BR>';
echo $gall;
}
?>
I know you see the same var names used by everyone, but that is just convention - they have no special significance or meaning. The names are used in code examples so that everyone can see what is what, and the logic of the example is made more general. In your own production code you should use more meaningfull names that relate to the application and then this sort of error probably would not happen.