I know this is an old thread, but I am trying to achieve the same results. Here's my code:
while ($row = mysql_fetch_array($result))
{
echo " ";
echo "<td>";
echo "<img src=\"images/$row[element_5]\" border=\"1\" width='$maxwidth' alt=\"$row[element_1]\"...