Hi,
My approch would be to create the ouput string before outputting to server,
i.e
$result=mysql_query("SELECT id, file FROM images WHERE rid='$tid'");
while($i=mysql_fetch_array($result)) {
$outputString .= "<td width=\"20%\" align=\"center\">\n";
$outputString .= "<a href=\"pics/" . $i['file'] . "\"><img src=\"pics/thumb/" . $i['file'] . "\ alt=\"\" /></a>\n</td>";
}
echo $outputString;
You will need to verify that all characters are properly placed according to your needs.
Next step is to store the content of $outputString into MySQL which is something I have not done with strings containing html characters and I'll leave it for others to comment.