![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Newbie
Join Date: Mar 2005
Posts: 3
Rep Power: 0
![]() |
Random banner rotator problem
Hi,
I'm trying to write a banner rotator script in PHP, one that doesn't use SSI to call or include() in a php script or anything. In other words, the way I want it to work is basically like WebAdverts back then (for perl), where you would include a static HTML on a regular HTML page like: <a href="http://www.mysite.com/bannerlink.php?pageid=123&whateverelse"> <img src="http://www.mysite.com/bannerdisplay.php?pageid=123&whateverelse"> </a> I'm thinking about using cookies to achieve this. but I would still need to include some sort of page ID that is different for every page that displays the banner, would I? is there any way I can have one piece of static code on all pages? also, even if I use page IDs, if a user goes to a page, then open a new window and go to that page again and a new banner is displayed, clicking the banner on the first window would still redirect to the wrong link, wouldn't it? What is a good solution to this problem? Please don't suggest the use of SSI or include() because the situation doesn't allow for it. Thanks! |
|
|
|
|
|
#2 |
|
Programmer
Join Date: Jan 2005
Location: Bayamon, Puerto Rico
Posts: 71
Rep Power: 4
![]() |
Thinking really quick.... two similars solutions come to my mind first one is have a script like bannerlink.php that redirect you using an id like you are doing on the example. Inside the script maybe an array or a switch that will select the correct redirection. (i dunno if you are going to enter this hardcoding or you are goint to prepare an page to insert them.) for the image i think 2 possible solutions first one is having a specific folder with the images name corresponding to the id of the link like img src="http://www.mysite.com/images/123.jpg, the otherone im not sure... but i think is possible... php can be used to generate other file types using the headers of the files and other stuff... if this is possible then you can use the same tecnique of the urls to the images like in your example.
-codetaino PS: Sorry about my errors, english is not my primary language EDIT: take a look of this code i found.. i played with it and managed to create a link with an image loaded dynamicly so... i think is posible just to have 2 files with correspondent ids for image and link and sending that id to load correspondents correctly without using includes or ssi... [PHP]<? //Just grab some general image info $img = "matrix.gif"; $path = "matrix.gif"; $imageInfo = GetImagesize($img); if ( $imageInfo[2] == 1 ) { //it's a gif $file = fread(fopen($path, "r"), filesize($path)); $fileHeader = "image/gif"; Header("Content-Type: ".$fileHeader); echo $file; fclose($file); } ?> [/PHP] note: this code will act as a gif, i used matrix.gif as an example but you can use any gif u like (including animated... mine was) to test it i did something like this... <a href="http://codetaino.is-a-geek.com"> <img src="http://codetaino.is-a-geek.com/testcode/img2.php"> </a>
__________________
"God bless u all" :) Last edited by codetaino; Mar 25th, 2005 at 10:36 AM. |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|