Spam Blaster Implemented
by NetriX - 4 months ago
The New PHP-Fusion USA
by NetriX - 7 months ago

Latest Posts

Fusion 9.0 Theme with Nebula
by jmonroe - 2 days ago
[PANEL] Top 5 Downloads
by alvin - 4 days ago
Facebook Connect 3.0.0
by FreedomIOPList - 3 weeks ago
Help With Userfield Generator In...
by FreedomIOPList - 3 weeks ago
Video Infusion 3.2.0
by songiuno - 1 month ago
Shoutbox refresh
by MarjorieMcCabe - 2 months ago
ArrowChat Details
by FreedomIOPList - 2 months ago
Need help
by penehoff - 2 months ago
Thank you
by KasteR - 3 months ago
Hello from newbie
by ginny - 3 months ago

View Thread

Who is here? 1 guest(s)
 Print Thread
Banner rotator
As the name says, this is a banner rotator made ??in php and html.

We create two files php and css

The first is the php file (Save to reklamy.php)
Download source  Code
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "">
<html xmlns="" xml:lang="pl">
      <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
      <meta name="robots" content="none"/>

      <link rel="stylesheet" type="text/css" href="style.css"/>
   $reklama[] = '<a href="" target="_blank"><img src="" alt=" - Twoje centrum NFS w Polsce" width="468" height="60" border="0"></a>';
   $reklama[] = '<a href="" title=" - Need for Speed, Shift, Nitro, World Online, Undercover, ProStreet, Carbon, Most Wanted, Underground 2, Underground" target="_blank"> <img src="" alt=" - Need for Speed, Shift, Nitro, World Online, Undercover, ProStreet, Carbon, Most Wanted, Underground 2, Underground" style="border:none;" /> </a>';
   $reklama[] = '<a href="" target="_blank" title="nfs, need for speed, shift, world online, nitro, undercover"><img src="" alt="nfs, need for speed, shift, world online, nitro, undercover" border="0"></a>';
   echo $reklama[rand(0,count($reklama)-1)];

The second image is a style (Save to styler.css)
Download source  Code


   border:solid 1px #000;


All put in the same directory with the name reklamy.

[fpnotice=info]I would recommend the application includes[/fpnotice]
Edited by Dzonson on 04-10-2013 23:28
Using this in PHPFusion 9 and works fine with php 7
This banner rotator is a little bit different from others, the banner will change only ones a day. I used the PHP function rand() because I think that MySQL’s “ORDER BY RAND()” and the PHP function array_rand() are only a second choice.

$db = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME);
// create table for the banners
`id` int(11) NOT NULL auto_increment,
`name` varchar(35) NOT NULL default '',
`link` varchar(150) NOT NULL default '',
`alt_title` varchar(100) NOT NULL default '',
`image` varchar(35) NOT NULL default '',
`ins_date` date NOT NULL default '0000-00-00',
`status` enum('on','off'Wink NOT NULL default 'on',
// create the table for storing todays banner id
CREATE TABLE `rand_banner` (
`id` int(11) NOT NULL auto_increment,
`date` date NOT NULL default '0000-00-00',
`todays_id` int(11) NOT NULL default '0',
// first check if todays banner id is already stored
$check_today_sql = "SELECT todays_id FROM rand_banner WHERE date = NOW()";
$check_today_res = $db->query($check_today_sql);
if ($check_today_res->num_rows) > 0) {
$today = $check_today_res->fetch_object();
$id_today = $today->todays_id;
} else {
// if not select a random id and store the id in the table with current date
$get_ids_sql = "SELECT id FROM banners WHERE status = 'on'";
$get_ids_res = $db->query($get_ids_sql);
$get_ids_array = array();
while ($get_ids = $get_ids_res->fetch_object()) {
$get_ids_array[] = $get_ids->id;
$num = count($get_ids_array);
// I use the function rand() because other random functions are not "really random"
$rand_num = rand(0, $num-1);
$id_today = $get_ids_array[$rand_num];
$db->query("INSERT INTO rand_banner (id, date, todays_id) VALUES (NULL, NOW(), $id_today)"Wink;
// at least select the record with the todays ID
$result = $db->query("SELECT link AS url, alt_title, image FROM banners WHERE id = $id_today"Wink;
$obj = $result->fetch_object();
// this example will show the current banner
echo "<a href=\"".$obj->url."\"><img src=\"/images/banners/".$obj->image."\" alt=\"".$obj->alt_title."\" border=\"0\"></a>";
Wasn't interested in using mysql :-), BUT can you edit this again and use the code function so all the smilel faces don't appear :-) This way those that want it can use it...
Jump to Forum:

Similar Threads

Thread Forum Replies Last Post
Header Banner Issues [7.02.XX] General Development 3 12-07-2014 11:09