How can i make a rotating 468x60 banner at the header of my directory http://prwebdir.com ? It's now non-rotating but I would like to make it rotating, how to do that? Thanks, Adam.
Do you mean a banner which animates, and shows different frames over a period of time? Or a banner which changes on every page load, e.g. you might have 10 different banners you want to display, and have them show up randomly to visitors? (I'm assuming the latter, since you're offering an ad placement service there)
If you want one banner followed by next banner,use java applets. Using the .class file with parameters passed by its html tag.
Are you planning on coding something like this yourself? (if not, then I think there should be pre-existing banner rotation systems available) If you're using PHP then a simple (very simple) example might go something like this $banner1 = "banners/banner1.jpg"; $banner2 = "banners/banner2.jpg"; $banner3 = "banners/banner3.jpg"; $banner_array = array($banner1, $banner2, $banner3); <img src="<?php echo $banner_array[rand(0,2)] ?>"/> --basically, all this is doing is storing the locations of the banners and then choosing one at random (the rand(0,2) function selects randomly between array location 0, 1 and 2) For a true banner rotation service though, you might want to store all the banners in a database, along with info about how many times they are to be shown per month. You should also make sure that they don't all get shown at once (like all 1000 displays within the first day, or something) All this would require a fair knowledge of PHP and MySQL (or whatever database is being used) though - or I guess you could do the same with text files. Let me know if I've just gone right over your head with this too
I just want to know how to mak 5 468x60 banners on my dir header to rotate randomly for the time they've been purchased for, like 1 month...will this work?
Yeah, I guess if that's all you're looking for, then what I suggested should work perfectly (just add higher numbers in rand() for more banners - well, I'm sure you can work all that out ). You'll probably do best just manually adding in the addresses pointing to each image, and then changing them at the end of the month
something like "banners/banner1.jpg" would be a "relative path" i.e. if your website is "http://www.website.com" and your banner is located at "http://www.website.com/banners/banner1.jpg", you would be able to use "banners/banner1.jpg" to reference it from the <img> tag It's probably best if you use something like... $banner1 = "http://www.website.com/banners/banner1.jpg"; $banner2 = "http://www.website.com/banners/banner2.jpg"; ... etc. though, keep things simple.
actually, think I misread your question sorry You could use another array, perhaps called $address_array = array("http://www.website1.com", "http://www.website2.com", "http://www.website3.com"); and then use the code $chosen_banner = rand(0,2); <a href="<?php echo $address_array[$chosen_banner]; ?>"><img src="<?php echo $banner_array[$chosen_banner]; ?>"/></a> (just moving the random number into a variable, $chosen_banner, there)
I'm totaly confused now Could you please make me a ready to go code for example 2 banners? I think I'd be able to make the 5 later.
Yeah, I think I got a little carried away there Here's how it should look... <?php $banner1 = "http://www.yoursite.com/banners/banner1.jpg"; $banner2 = "http://www.yoursite.com/banners/banner2.jpg"; $banner3 = "http://www.yoursite.com/banners/banner3.jpg"; $banner_array = array($banner1, $banner2, $banner3); $address_array = array("http://www.website1.com", "http://www.website2.com", "http://www.website3.com"); $chosen_banner = rand(0,2); ?> <a href="<?php echo $address_array[$chosen_banner]; ?>"><img src="<?php echo $banner_array[$chosen_banner]; ?>"/></a> Code (markup):
The code itself should work, I tested it on my local server. I think something's not right with the PHP processing on your server though - I can see the PHP code (including the <?php and ?> tags) within the source code for the page (have a look at "view source" yourself, you'll see the php code still present in the text of the page) The index file's got a .php extension, so it should be working. It's something you'd need to check with your hosting provider I guess
I got the ad placed in a .tpl file becuase it was there by defualt... So it seems like .tpl doesn't support .php? Is there any other way then?
You know, I've never understood why people open and close php so bloody much. It's just a waste of code, and makes flow logic a stone cold ***** Simplify, simplify, simplify - and don't restate values you shouldn't have to. <?php $banner_list = array( array('banner1.jpg','www.website1.com'), array('banner2.jpg','www.website2.com'), array('banner3.jpg','www.website3.com') ); $chosen_banner=rand(0,count($banner_list)); echo ' <a href="http://',$banner_list[$chosen_banner][1],'"> <img src="http://www.yoursite.com/banners/',$banner_list[$chosen_banner][0],'"/> </a> '; ?> Code (markup): -- edit -- changed it to automatically count the number of links.
As a rule no... you cannot mix SSI/CGI's. Out of curiousity, what are you using server side to parse your .tpl? DocFlex? XSLT? Ruby? If ruby - all we need to do is rewrite this method in that... Either that or you throw that bloated slow pile of crap out the window and recode the whole site in php. Probably should have asked that up front - I assumed because everyone else wrote php examples you were using PHP - if you are using Ruby, then no you can't put php inside ruby any more than you could put ruby inside php. SSI/CGI's do not blend - once you start using one you CANNOT use another. Unfortunately I don't know Ruby apart from some of it's base syntax, which was enough for me to toss it in the trash for being a huge step BACKWARDS technologically... There's a reason we don't use fortran or smalltalk anymore.
it was just a quick example I do aim to reduce open/closing as much as possible, but for large chunks of code, the endless streams of apostrophes and quotes and checking they all match up gives me a headache
Well, THAt .tpl file is for the header banner ONLY. It contained a html code by default with the banner. So far I've been using this code: <a href="http://prwebdir.com/contact.php"><img src="http://prwebdir.com/images/468x60.gif" border="1" alt="Header Ad"/></a>