Jump to content

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>';
								}
							?>
Edited by Jaymore
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>';
Edited by Ch0cu3r
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.