Thanks Corey, it works but it is not quite what I am trying to do. The modified piece of your code below is what I am trying to do but once again it only prints out one photo (category).
Basically I have a category which is a particular town, I also have other categories (Castles, Cathedrals, Abbeys etc) which I am trying to put on the bottom off the particular town if they are in the town, so I put the name of the town in the description (WHERE description='$town') from this I select a field called thumbnail which is a id of a photo that I would like to display. So for example London would select Westminster Abbey, The Tower of London etc and their corresponding thumbnails i.e 100, 200 and foreach of these thumbnails I would like to get the photo details from pp_photos i.e cat, bigimage etc.
$result = mysql_query("SELECT thumbnail FROM pp_categories
WHERE description='$town' AND parent = '533'") or die(mysql_error());
while($row = mysql_fetch_array( $result )) {
$thumbnail=$row['thumbnail'];
$query = "SELECT id, cat, bigimage FROM pp_photos WHERE id=$thumbnail";
$resource = mysql_query($query) or die(mysql_error());
while ($result = mysql_fetch_array($resource)) {
print "<a href=/photos/showgallery/cat/" .
$result['id'] . ".php><img src=/photos/data/" . $result['cat'] . "/thumbs/" .
$result['bigimage'] . " border=0 class=relatedthumb></a>";
}
}