I want this script to get the pictures with the id of persons in a database, this works.
But when there are no picture with correct id in the folder I want the script to show a "No picture"-picture, but this doesn´t work with this script. Why not?
<?php
$hamta = "SELECT * FROM persons ORDER BY name";
$resultat = mysql_query($hamta) or die("Error!");
while($rad = mysql_fetch_array($resultat))
{
$pictures = glob('pictures/' . $rad['id'] . '.jpg');
if (count($pictures) > 0) {
foreach($pictures as $picture) {
echo '<img src="', $picture, '" alt="" />';
}
} else {
echo '<img src="pictures/no_picture_.jpg" alt="No picture" />';
}
}
mysql_free_result($resultat);
?>