kidintraffic Posted May 5, 2007 Share Posted May 5, 2007 I have a form that a user can enter data and upload an image that is stored in a database. The user doesn't have to upload an image but has to enter data into the rest of the form. When pulling the information from the database I was wondering how you would say if the database name for the image is empty then display a default image. and if there is data in the database for the image name then display the image specified. I know to display the image that is in the database I use this code <img src="uploads/<? echo $imgname; ?>" /> Link to comment https://forums.phpfreaks.com/topic/50157-solved-if-statement-for-database/ Share on other sites More sharing options...
triphis Posted May 5, 2007 Share Posted May 5, 2007 $imgname (pulled from that cell in the DB table) if($imgname == NULL) // or whatever you set as default { echo "<img src='default.gif'>" /> } else { echo "<img src='uploads/<?=$imgname?>' />" } edit: When the form is submitted, you can check to see if they are uploading something or not, and then set the DB cell to whatever you decide Then check based on that. Link to comment https://forums.phpfreaks.com/topic/50157-solved-if-statement-for-database/#findComment-246285 Share on other sites More sharing options...
kidintraffic Posted May 5, 2007 Author Share Posted May 5, 2007 When the form is submitted, you can check to see if they are uploading something or not, and then set the DB cell to whatever you decide Then check based on that. How would I do that? Link to comment https://forums.phpfreaks.com/topic/50157-solved-if-statement-for-database/#findComment-246288 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.