computel Posted July 21, 2010 Share Posted July 21, 2010 I have this code that displays banners of two types. a banner that shows 468x60 and then two random banners of 120x240 & 120x600 sizes the banners are called by the script <?=show_banner("1");?> & <?=show_banner("2");?> I want to have a 3rd banner location of 728x90 and call it like this <?=show_banner("3");?> how would I change the code below to do this? Thanks function banner_sizes($s) { $sizes_array = array("468x60", "120x240", "120x600"); $select = "<select name=\"BannerSize\">\n\t"; foreach($sizes_array as $b) { if($s == $b) { $select .= "<option value=\"$b\" selected>$b</option>\n\t"; } else { $select .= "<option value=\"$b\">$b</option>\n\t"; } } $select .= "</select>"; return $select; } function show_banner($bs) { /* $bs = 1 (468x60) and 2 (random from 120x240, 120x600) */ global $dir; if($bs == '1') { $new_bs = "('468x60')"; } else { $new_bs = "('120x240', '120x600')"; } $q1 = "select * from games_banners where BannerSize in $new_bs order by rand() limit 0,1 "; $r1 = mysql_query($q1) or die(mysql_error()); $a1 = mysql_fetch_array($r1); if($a1[bannerType] == "link_code") { $banner_html = $a1[LinkCode]; } else { $size = explode("x", $a1[bannerSize]); $banner_html = "<a href=\"$a1[bannerURL]\" target=\"_top\"><img src=\"http://$_SERVER[HTTP_HOST]$dir/bfiles/$a1[bannerFile]\" alt=\"$a1[bannerAlt]\" border=0 width=\"$size[0]\" height=\"$size[1]\"></a>"; } return $banner_html; } Quote Link to comment https://forums.phpfreaks.com/topic/208439-how-to-show-a-3rd-banner-type/ Share on other sites More sharing options...
radar Posted July 22, 2010 Share Posted July 22, 2010 this is quite simple given that code. First off you need to add the new size into the $sizes_array so that would be changed from: $sizes_array = array("468x60", "120x240", "120x600"); to $sizes_array = array("468x60", "120x240", "120x600", "728x90"); Next we need to change the show_banner function to read your optional attribute of 3. So change this: if($bs == '1') { $new_bs = "('468x60')"; } else { $new_bs = "('120x240', '120x600')"; } to this: if($bs == '1') { $new_bs = "('468x60')"; } else if($bs == '3') { $new_bs = "('728x90')"; } else { $new_bs = "('120x240', '120x600')"; } [/code] and it should work for you. Quote Link to comment https://forums.phpfreaks.com/topic/208439-how-to-show-a-3rd-banner-type/#findComment-1089652 Share on other sites More sharing options...
computel Posted July 22, 2010 Author Share Posted July 22, 2010 Thank I will give this a try and let you know how it turns out. Quote Link to comment https://forums.phpfreaks.com/topic/208439-how-to-show-a-3rd-banner-type/#findComment-1089819 Share on other sites More sharing options...
computel Posted July 23, 2010 Author Share Posted July 23, 2010 Worked 100% Thanks Quote Link to comment https://forums.phpfreaks.com/topic/208439-how-to-show-a-3rd-banner-type/#findComment-1089866 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.