Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Jan 30th, 2008, 11:49 AM   #1
kinuthia
Newbie
 
Join Date: Jun 2007
Posts: 15
Rep Power: 0 kinuthia is on a distinguished road
Post Adrotator

Hello all,
Can someone tell me how to use an adrotator in php. In asp you can use <asp:adrotator:............................. />

I need to do the same in php.
Please help.
Thanks all.
kinuthia is offline   Reply With Quote
Old Jan 30th, 2008, 11:56 AM   #2
Sane
Programming Guru
 
Sane's Avatar
 
Join Date: Apr 2005
Location: Waterloo, Ontario
Posts: 1,886
Rep Power: 5 Sane will become famous soon enough
Send a message via MSN to Sane
Re: Adrotator

You could make one very easily yourself. In fact, it's already been done. http://www.phpbuddy.com/article.php?id=4

If it doesn't fit your needs, just modify/extend it. Or search "php adrotater" on Google.
Sane is offline   Reply With Quote
Old Jan 30th, 2008, 6:13 PM   #3
kinuthia
Newbie
 
Join Date: Jun 2007
Posts: 15
Rep Power: 0 kinuthia is on a distinguished road
Re: Adrotator

Thanks alot Sane.

I have tried but for some reasons its not working.

Last edited by kinuthia; Jan 30th, 2008 at 6:40 PM.
kinuthia is offline   Reply With Quote
Old Jan 31st, 2008, 12:29 PM   #4
Sane
Programming Guru
 
Sane's Avatar
 
Join Date: Apr 2005
Location: Waterloo, Ontario
Posts: 1,886
Rep Power: 5 Sane will become famous soon enough
Send a message via MSN to Sane
Re: Adrotator

Could you post the code? What exactly is the problem?
Sane is offline   Reply With Quote
Old Feb 1st, 2008, 6:12 AM   #5
kinuthia
Newbie
 
Join Date: Jun 2007
Posts: 15
Rep Power: 0 kinuthia is on a distinguished road
Re: Adrotator

Thanks Sane. I think the code is okey. I tested it in a different page and it works okey. The thing is i'm trying to use it in a templated website and that is where its not working. I think i have to create another function to handle this. I honestly don't know how to do it but im still trying to look for ways. Im not an expert in PHP but just started to learn it a month ago.
kinuthia is offline   Reply With Quote
Old Feb 1st, 2008, 8:10 AM   #6
Sane
Programming Guru
 
Sane's Avatar
 
Join Date: Apr 2005
Location: Waterloo, Ontario
Posts: 1,886
Rep Power: 5 Sane will become famous soon enough
Send a message via MSN to Sane
Re: Adrotator

You could wrap the code I linked to, into a function, and save it as a separate PHP script.

adrotater.php

PHP Syntax (Toggle Plain Text)
  1. <?php
  2.  
  3. function adrotater($filename) {
  4. $fcontents = join ('', file ($filename));
  5. $s_con = split("~",$fcontents);
  6.  
  7. $banner_no = rand(0,(count($s_con)-1));
  8. echo $s_con[$banner_no];
  9. }
  10.  
  11. ?>

Place the above file, adrotater.php, in the same directory as your other scripts. This would allow you to use the function, in your main PHP file, like so:

index.php

PHP Syntax (Toggle Plain Text)
  1. <?php
  2.  
  3. // Include the separate PHP script
  4. include('adrotater.php');
  5.  
  6. //
  7. // Blah blah blah, some code here
  8. //
  9.  
  10. // Display a random advertisement from banner_ads.txt
  11. adrotater('banner_ads.txt');
  12.  
  13. //
  14. // More code here
  15. //
  16.  
  17. ?>

Make sure to include the adrotater.php file in every file you want to use the adrotater function.

Then the argument passed to it, 'banner_ads.txt', is the text file with the advertisements inside.
Sane is offline   Reply With Quote
Old Feb 3rd, 2008, 2:16 PM   #7
Ooble
I eat cake for breakfast.
 
Ooble's Avatar
 
Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9 Ooble is on a distinguished road
Re: Adrotator

Does PHP's rand function return numbers uniformly? If it doesn't, it's probably a poor choice for this sort of thing.

As an aside, it's spelt "rotator." No offence, Sane.
__________________
Me :: You :: Them
Ooble is offline   Reply With Quote
Old Feb 3rd, 2008, 6:17 PM   #8
Sane
Programming Guru
 
Sane's Avatar
 
Join Date: Apr 2005
Location: Waterloo, Ontario
Posts: 1,886
Rep Power: 5 Sane will become famous soon enough
Send a message via MSN to Sane
Re: Adrotator

It would return it uniformly enough. Anything random would be good enough for an adrotator.

And wow, I had no clue I was spelling that incorrectly. Thanks for the correction.
Sane is offline   Reply With Quote
Old Feb 3rd, 2008, 6:21 PM   #9
kinuthia
Newbie
 
Join Date: Jun 2007
Posts: 15
Rep Power: 0 kinuthia is on a distinguished road
Re: Adrotator

Ooble
Any alternatives.
kinuthia is offline   Reply With Quote
Old Feb 3rd, 2008, 6:24 PM   #10
kinuthia
Newbie
 
Join Date: Jun 2007
Posts: 15
Rep Power: 0 kinuthia is on a distinguished road
Re: Adrotator

Sane

Im still trying to figure this out. I have to incorperate the function in other functions list where it will be called from.
kinuthia is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 10:48 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC