dirigibleplum
dirigibleplum

Reputation: 137

Displaying default image for users with no profile picture

I have this code for showing the profile picture of the user who has logged in:

<ul>
  <li>
    <img src="images/<?php echo $row_user['profilepic']; ?>">
  </li>
  ...
</ul>

How do I include a deafultimage.jpg if the user has no profile picture?

Upvotes: 2

Views: 419

Answers (1)

Fabio
Fabio

Reputation: 23500

Check if $row_user['profilepic'] is empty and print according

<ul>
  <li>
    <img src="images/<?php echo !empty($row_user['profilepic']) ? $row_user['profilepic'] : 'deafultimage.jpg'; ?>">
  </li>
  ...
</ul>

Upvotes: 3

Related Questions