squiblo Posted July 29, 2009 Share Posted July 29, 2009 ok my aim here is to view the profile image if they have uploaded one, but if they have not uploaded one i want to view another image, i have started already but got stuck trying to view another image if they havent uploaded one... <?php session_start(); include("checklogin.php"); $username = $_SESSION['myusername']; $query = mysql_query("SELECT * FROM members WHERE username='$username'"); if (mysql_num_rows($query)==0) die("User not found!"); else { $row = mysql_fetch_assoc($query); $location = $row['imagelocation']; echo "<img src ='$location' width='225' height='275'>"; } ?> the path to the image if they havent uploaded one is... /profileimages/box.png Quote Link to comment https://forums.phpfreaks.com/topic/168017-solved-else-statement/ Share on other sites More sharing options...
arkansasonline Posted July 29, 2009 Share Posted July 29, 2009 If I understand what you want to do correctly. After your if remove the die and echo the other image. **Edit** I did not understand correctly. In your else you could do if($location!='') echo "<img src ='$location' width='225' height='275'>"; else echo "<img src='/profileimages/box.png'>"; Quote Link to comment https://forums.phpfreaks.com/topic/168017-solved-else-statement/#findComment-886173 Share on other sites More sharing options...
p2grace Posted July 29, 2009 Share Posted July 29, 2009 Something like this should do the trick. <?php session_start(); include("checklogin.php"); $username = $_SESSION['myusername']; $query = mysql_query("SELECT * FROM members WHERE username='$username'"); if (mysql_num_rows($query)==0){ die("User not found!"); }else{ $row = mysql_fetch_assoc($query); $location = $row['imagelocation']; if($location == ""){ echo "<img src ='/profileimages/box.png' width='225' height='275'>"; }else{ echo "<img src ='$location' width='225' height='275'>"; } } ?> Quote Link to comment https://forums.phpfreaks.com/topic/168017-solved-else-statement/#findComment-886175 Share on other sites More sharing options...
squiblo Posted July 29, 2009 Author Share Posted July 29, 2009 that worked perfect thankyou, i have linked the images, but it puts a purple border on, how can i stop this? <div id="wb_Shape5" style="position:absolute;left:84px;top:240px;width:225px;height:275px;z-index:11" align="center"><a href="/upload.php"> <?php session_start(); include("checklogin.php"); $username = $_SESSION['myusername']; $query = mysql_query("SELECT * FROM members WHERE username='$username'"); if (mysql_num_rows($query)==0){ die("User not found!"); }else{ $row = mysql_fetch_assoc($query); $location = $row['imagelocation']; if($location == ""){ echo "<img src ='/profileimages/box.png' width='225' height='275'></a>"; }else{ echo "<img src ='$location' width='225' height='275'>"; } } ?> </a></div> Quote Link to comment https://forums.phpfreaks.com/topic/168017-solved-else-statement/#findComment-886191 Share on other sites More sharing options...
arkansasonline Posted July 29, 2009 Share Posted July 29, 2009 give the image a style attribute of echo "<img src ='/profileimages/box.png' width='225' height='275' style='border-style:none'></a>"; Quote Link to comment https://forums.phpfreaks.com/topic/168017-solved-else-statement/#findComment-886196 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.