Jaymore Posted August 10, 2014 Share Posted August 10, 2014 Hello im learning php but im getting hard time trying to figure something out how do you add a placeholder or default image on a php im trying to add image but when i see its all blank where should i put my placeholder for my image ? echo '<a rel="facebox" href="editpic.php?id='.$row['id'].'"><img src=../'.$row['ppic'].' width="200" height="200" style="float:left; margin-right:10px;"></a>'; echo 'Name:'.$row['fname'].' '.$row['mname'].' '.$row['lname'].'<br>'; echo 'ID Number:'.$row['idnumber'].'<br>'; echo 'Password:'.$row['password'].'<br>'; echo 'Gender:'.$row['gender'].'<br>'; echo 'Birthday:'.$row['bday'].'<br>'; echo 'Email:'.$row['email'].'<br>'; echo 'Address:'.$row['address'].'<br>'; echo 'Age:'.$row['age'].'<br>'; echo 'yearlevel:'.$row['yearlevel'].'<br>'; echo 'Section:'.$row['section'].'<br>'; } ?> Link to comment https://forums.phpfreaks.com/topic/290376-how-to-add-a-placeholder-image-in-php/ Share on other sites More sharing options...
davidannis Posted August 10, 2014 Share Posted August 10, 2014 need quotes around src=blah so it is src="blah" <img src=../'.$row['ppic'].' should be <img src="../'.$row['ppic'].'" Link to comment https://forums.phpfreaks.com/topic/290376-how-to-add-a-placeholder-image-in-php/#findComment-1487332 Share on other sites More sharing options...
Ch0cu3r Posted August 10, 2014 Share Posted August 10, 2014 Hello im learning php but im getting hard time trying to figure something out how do you add a placeholder or default image on a php im trying to add image but when i see its all blank where should i put my placeholder for my image ? Sorry what? You mean to say you want to display a default placholder image if the user has not provided one? You just need a simple if // default placeholder image $pic = 'placeholder.gif'; // if user has provided a picture, override default image if(!empty($row['ppic'])) { $pic = $row['ppic']; } echo '<a rel="facebox" href="editpic.php?id='.$row['id'].'"><img src="../'.$pic.'" width="200" height="200" style="float:left; margin-right:10px;"></a>'; Link to comment https://forums.phpfreaks.com/topic/290376-how-to-add-a-placeholder-image-in-php/#findComment-1487333 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.