Could someone please show me where i'm going wrong here, i've been at it for hours and cannot seem to get this to work...
Pictures showing if member has uploaded...
When upload a pic it puts details in mysql DB (picture.jpg)

I'm having an issue trying to show a default pic if a picture hasn't been uploaded.
I've tried various different ways including numrows but somethings not right i'm not getting the default picture for some reason....
Any help would be appriciated Thank you

```
$sql_com = mysqli_query($db_conx, "SELECT `photo` FROM `members` ORDER BY `members`.`registered` DESC LIMIT 7");
$hpmembers = '';
while($row = mysqli_fetch_array($sql_com)){ 
$photo = $row["photo"];

if (file_exists('photos/' . $photo . '')) {
    $user_pic = '<img src="photos/' . $photo . '" width="94" height="94" border="0" style="padding:2px;border:#e6e6e6 solid 1px;margin:3px;" />';
}else{
    $user_pic = '<img src="photos/avatar.gif" width="94" height="94" border="0" style="padding:2px;border:#e6e6e6 solid 1px;margin:3px;" />';   
}

    $hpmembers .= '' . $user_pic . '';
}

```

Also tried:

```
$sql_com = mysqli_query($db_conx, "SELECT `photo` FROM `members` ORDER BY `members`.`registered` DESC LIMIT 0, 14");
$i = 0;
$hpmembers = '<table border="0" cellpadding="5">';
$num_rows = $sql_com->num_rows;
while($row = mysqli_fetch_array($sql_com)){ 
$photo = $row["photo"];

if ((file_exists('photos/' . $photo . '')) && ($num_rows > 0)) {
    $user_pic = '<img src="photos/' . $photo . '" width="50" height="50" border="0" />';
}else{
    $user_pic = '<img src=\"photos/avatar.gif\" width="50px" height="50px" border="0" />';  
}

if ($i % 7 == 0) {
    $hpmembers .= '<tr><td>' . $user_pic . '</td>';
} else {
    $hpmembers .= '<td>' . $user_pic . '</td>';
}
$i++;
}
$hpmembers .= '</tr></table>';

```