augment Posted October 11, 2011 Share Posted October 11, 2011 Hi there, I am scratching my head for ages trying to get this to work. I am adapting a script that simply outputs a floorplan image from a MySQL database. Only problem is that it outputs the <DIV> and all the title and formatting even if no image exists. I only want to output the <DIV> if an image exists. Thanks in advance for any help. Charlotte <div id="property-contact"> <h2 id="h2-section" class="h2-section"><?php _e('Floor Plan',TS_DOMAIN) ?></h2> <div class="box2 clearfix"> <?php $floor_plans_image_id =get_post_meta($post->ID, "_thumbnail_id", true); $myrows = $wpdb->get_results( "SELECT guid FROM wp_posts WHERE ID=".$floor_plans_image_id ); ?> <a href="<?=$myrows[0]->guid?>" rel="prettyPhoto[gallery]"><img src="<?=$myrows[0]->guid?>" width="250px;"/></a> </div><!-- end box3 --> </div> Link to comment https://forums.phpfreaks.com/topic/248917-newbie-question/ Share on other sites More sharing options...
AyKay47 Posted October 11, 2011 Share Posted October 11, 2011 if(!empty($myrows[0]->guid)){ // show image } Link to comment https://forums.phpfreaks.com/topic/248917-newbie-question/#findComment-1278346 Share on other sites More sharing options...
augment Posted October 11, 2011 Author Share Posted October 11, 2011 Fantastic, didn't think it was as easy to embed PHP within HTML within PHP. Clever stuff. thanks a million, Charlotte Link to comment https://forums.phpfreaks.com/topic/248917-newbie-question/#findComment-1278368 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.