Jump to content

How To Add A Placeholder Image In Php


Jaymore

Recommended Posts

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

 

 

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>';

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.