Best way to include banner

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Miha
Forum Newbie
Posts: 10
Joined: Mon Aug 21, 2006 12:44 pm

Best way to include banner

Post by Miha »

Hi,

what's the best way, to include banner into a page, so that the page administrator can change/upload new banner without changing page's sourcecode. I'm using php technology with MySQL on this page. I also built administrator section for adding news, maybe i should add something for a banner? Banners will be in .swf and .gif format.
Any suggestions how to do this??

regards, Miha.
User avatar
Benjamin
Site Administrator
Posts: 6935
Joined: Sun May 19, 2002 10:24 pm

Post by Benjamin »

Might want to save time and see if you can find a decent banner manager on hotscripts.com
jabbaonthedais
Forum Contributor
Posts: 127
Joined: Wed Aug 18, 2004 12:08 pm

Post by jabbaonthedais »

You could include a banner.php page that just had the banner image name and url. If you wanted it to swap out, you could write a script to randomly show a different banner each time.
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

I store my banner code in my datanbase and then show a different one based on a rand() order from the database on each page load. I also use this technique for changing heading text on certain parts of my site.

Code: Select all

SELECT `banner_url`, `banner_img`, `banner_alt` FROM `banners` ORDER BY RAND() LIMIT 0, 1;
User avatar
Benjamin
Site Administrator
Posts: 6935
Joined: Sun May 19, 2002 10:24 pm

Post by Benjamin »

MySQL's rand function is garbage.
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

For little things like this, it as served its purpose for me.
Miha
Forum Newbie
Posts: 10
Joined: Mon Aug 21, 2006 12:44 pm

Post by Miha »

I solved my problem. I made an admin page, where administrator can upload a file(.swf or .gif) and link. File is uploaded into some directory on server, filename and link is stored into MySQL. To include a banner on a page i wrote a simple function. It just gets filename and link from database(the last one), finds out whitch type of file it is, and depending on that, it echos out <a href='link'....<img.....'filename'... or swf object with 'filename'...
Post Reply