echo $rest_of_entry; if($first_picture is in database) { echo "<img src = ....etc "; } if($second_picture is in database) { echo "<img src = ....etc "; }