So the function was for running once. This was for polling for multiple users:
<?php
$path_to = 'http://mysite.com/'; // with trailing slash
$image_folder = 'profilepics/'; // with trailing slash
$sql = mysql_query('SELECT `file`,`caption` FROM `profilepic`') or die(mysql_error());
if (mysql_num_rows($sql) != 0) {
while($r = mysql_fetch_row($sql)) {
$file = stripslashes($r[0]);
$caption = stripslashes($r[1]);
echo '<img src="' . $path_to . $image_folder . $file . '" alt="caption" border="0" /><br />' . $caption;
}
} else {
echo 'I have no pic, I must be ugly!';
}
?>
With a well designed database, I have found that joins are rarely needed. I believe it is just one pic per user, I could be wrong.