Dannyeo Posted December 14, 2012 Share Posted December 14, 2012 Hi Would anyone be able to offer some advice? Currently stuck. I have the following code within a PHP file that controls the header banners on my website. function pokies_header_468_60_banner() { ?> <div class="header_banner" > <?php echo adrotate_group(16); ?> </div> <?php } The banners are not appearing on the site and I think its down to me incorrectly using div and php together in the above code. Any advice would be appreciated - sorry if this is simple but I'm new to this and learning as I go along Quote Link to comment https://forums.phpfreaks.com/topic/271991-php-code-and-div-tags/ Share on other sites More sharing options...
Langstra Posted December 14, 2012 Share Posted December 14, 2012 You put this in a function, you do not echo anything. You put this in a file and include it on your website. Quote Link to comment https://forums.phpfreaks.com/topic/271991-php-code-and-div-tags/#findComment-1399349 Share on other sites More sharing options...
gristoi Posted December 14, 2012 Share Posted December 14, 2012 (edited) your mixing function and output. you need to do something along these lines: <?php function pokies_header_468_60_banner() { $output = '<div class="header_banner" >'; $output .= adrotate_group(16); $output .= '</div>'; return $output; } ?> then where you need to print it out: <?php print pokies_header_468_60_banner(); ?> Edited December 14, 2012 by gristoi Quote Link to comment https://forums.phpfreaks.com/topic/271991-php-code-and-div-tags/#findComment-1399350 Share on other sites More sharing options...
Dannyeo Posted December 14, 2012 Author Share Posted December 14, 2012 (edited) Thanks for our help. I've tried the code above but it is crashing the site. It is definitely the div code that is causing me problems. For example I have some sidebar banners that work with the following code: function pokies_sidebar_160_600_banner() { ?> <?php echo adrotate_group(13); ?> <?php } So the real issue I have is how to incorporate the <div class="header_banner" > into the following code which isn't working: function pokies_header_468_60_banner() { ?> <div class="header_banner" > <?php echo adrotate_group(16); ?> </div> <?php } Edited December 14, 2012 by Dannyeo Quote Link to comment https://forums.phpfreaks.com/topic/271991-php-code-and-div-tags/#findComment-1399364 Share on other sites More sharing options...
NomadicJosh Posted December 14, 2012 Share Posted December 14, 2012 If you view the source code of the page, for that section, what do you see? Quote Link to comment https://forums.phpfreaks.com/topic/271991-php-code-and-div-tags/#findComment-1399366 Share on other sites More sharing options...
Dannyeo Posted December 14, 2012 Author Share Posted December 14, 2012 I'm seeing what I think I should be seeing in the source code: <div class="header_banner" > <a href="http://www.domain.com" rel="nofollow" target="_blank"><img src="http://imagelocation.com/image.gif" /></a> </div> Quote Link to comment https://forums.phpfreaks.com/topic/271991-php-code-and-div-tags/#findComment-1399371 Share on other sites More sharing options...
Dannyeo Posted December 14, 2012 Author Share Posted December 14, 2012 An extract from the css is .header_banner { float: right; margin-top: 38.5px; margin-right: 50px; position:relative; overflow:hidden; width:468px; height:60px; } .header_banner a { /*opacity:0; filter:alpha(opacity=0);*/ display:none; position:absolute; top:0px; left:0px; } Quote Link to comment https://forums.phpfreaks.com/topic/271991-php-code-and-div-tags/#findComment-1399372 Share on other sites More sharing options...
mrMarcus Posted December 14, 2012 Share Posted December 14, 2012 display:none; Means to display none/hide. Remove it from your CSS. Quote Link to comment https://forums.phpfreaks.com/topic/271991-php-code-and-div-tags/#findComment-1399373 Share on other sites More sharing options...
Dannyeo Posted December 14, 2012 Author Share Posted December 14, 2012 I've just done a test by removing the div element. So the following code displays the banners in the header (though they are not in the correct place due to no mention to the CSS to align them): function pokies_header_468_60_banner() { ?> <?php echo adrotate_group(16); ?> <?php } So, the above works OK. Just the alignment of the banners is missing. So when I now add the CSS reference to align the banners it all stops working (despite the source code looking ok): function pokies_header_468_60_banner() { ?> <div class="header_banner" > <?php echo adrotate_group(16); ?> </div> <?php } Quote Link to comment https://forums.phpfreaks.com/topic/271991-php-code-and-div-tags/#findComment-1399375 Share on other sites More sharing options...
mrMarcus Posted December 14, 2012 Share Posted December 14, 2012 Have a feeling you missed my previous post. See here, or just look up. Quote Link to comment https://forums.phpfreaks.com/topic/271991-php-code-and-div-tags/#findComment-1399376 Share on other sites More sharing options...
Dannyeo Posted December 14, 2012 Author Share Posted December 14, 2012 Thanks mrMarcus - I just posted a reply at the same time as your post. Yes you are spot on. As soon as I made the change to the CSS display:none; by removing this line it is all working. Thanks for your help. Much appreciated. Quote Link to comment https://forums.phpfreaks.com/topic/271991-php-code-and-div-tags/#findComment-1399377 Share on other sites More sharing options...
Dannyeo Posted December 14, 2012 Author Share Posted December 14, 2012 Thanks again for everyones help on this. Quote Link to comment https://forums.phpfreaks.com/topic/271991-php-code-and-div-tags/#findComment-1399378 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.