im a little tired, but im guessing you just want it random instead of php pulling it with the same format everytime... if so use this:
PHP Code:
$result = @mysql_query("SELECT * FROM $TableName WHERE approved = 'Y' order by rand()");
while ( $row = mysql_fetch_array($result) ) {
$i++;
echo "<td><a href=gallery.php?id=$row[id]>$row[name]</a>\n";</td>n";
if (($i % 5) == 0) { echo "</tr><tr>n" ; }