How to set a default image

ok so I have the sql and the output for if someone has an image, how would I re-write this to set a default image if the user hasn't uploaded a profile picture?

$search = mysql_query("SELECT users.username, users.id, tbl_image.photo, tbl_image.userid FROM users LEFT OUTER JOIN tbl_image ON users.id=tbl_image.userid WHERE users.username LIKE '%$search_term%' and users.business <> 'business'");

<img src="/image/'.$results_row['photo'].'" width="50px" height="40px">

Answers


If the image is NULL or "", you use your default:

$image = $results_row['photo'];
if (empty($image)) $image = "default.png";
<img src="/image/'.$image.'" width="50px" height="40px">

Check to see if it's null or not. If it is, use a default photo.

$search = mysql_query("SELECT users.username, users.id, tbl_image.photo, tbl_image.userid FROM users LEFT OUTER JOIN tbl_image ON users.id=tbl_image.userid WHERE users.username LIKE '%$search_term%' and users.business <> 'business'");

$photo = $results_row['photo'] : $results_row['photo'] ? 'default_photo.jpg'

<img src="/image/'.$photo.'" width="50px" height="40px">

Need Your Help

VS2008. Make class defined in Project 1 visible in Project 2 inside the containing solution

silverlight silverlight-3.0

How can I make a class defined in Project 1 visible so I can declare objects of that type inside Project 2, if both projects are part of the same solution?