Associating photo with its caption details in a database

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.

thank you all…I’m working on it!

 
while($row = mysql_fetch_assoc($show)){
echo $row['userrname'];
echo '<img src="images/user1.jpg" />';
}

needs to be:

 
while($row = mysql_fetch_assoc($show)){
echo $row['username'];
echo '<img src="images/' . $row['image'] . '" />';
}

I have not had time to read the entire script but this should solve that issue.

@ LF…thanks!..that does the trick :smiley: