alexmark Posted April 27, 2012 Share Posted April 27, 2012 Hi all I have a MySQL data base that is saving information from a form. One the form a user can add a business name which is text and a logo if they have one. Now on my web page I want to beabe to display the picture if present if not I would like it to display the business name. How do I do this please. I know how to conect to DB etc just having problems getting my head around this problem. Quote Link to comment https://forums.phpfreaks.com/topic/261730-display-text-if-picture-not-present/ Share on other sites More sharing options...
plznty Posted April 27, 2012 Share Posted April 27, 2012 $mysqlqueryresult = ''; if ( empty($mysqlqueryresult) ) { // For default image // echo '<img src="defaultimage.jpg" />'; // For Text // echo $theQueryToGetText; } else { echo '<img src="theUrlOfTheImage.jpg" />'; } Some code would be more useful for me or others to assist you. Quote Link to comment https://forums.phpfreaks.com/topic/261730-display-text-if-picture-not-present/#findComment-1341257 Share on other sites More sharing options...
alexmark Posted April 27, 2012 Author Share Posted April 27, 2012 What code would you like? Quote Link to comment https://forums.phpfreaks.com/topic/261730-display-text-if-picture-not-present/#findComment-1341276 Share on other sites More sharing options...
QuickOldCar Posted April 28, 2012 Share Posted April 28, 2012 http://php.net/manual/en/function.file-exists.php if(file_exists($mysql_image)){ echo "<img src='$mysql_image' />"; } else { echo $mysql_bus_name; } Quote Link to comment https://forums.phpfreaks.com/topic/261730-display-text-if-picture-not-present/#findComment-1341285 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.