<?
/*
Random Banner Rotation with PHP4 and MySQL
-------
Author: Anton Suryawan (heads103@flashmail.com)
After I looked at "Automatic banner rotation. Randomly selects a banner for display
by Anton
Olsen(aolsen@graphweb.com)"
on http://www.weberdev.com/get_example.php3?count=400,
I tried to create my own banner with PHP4 and MySQL. This is just a test. Did not
test it yet
with
heavy traffic websites. But the result is sometime the random number _is_not_ really
a
random.
This is the Database Sample:
---------------------------------------------------
CREATE TABLE `tbl_d_banner` (
`bannerid` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
`src` VARCHAR(128) NOT NULL DEFAULT '',
`href` VARCHAR(128) NOT NULL DEFAULT '',
`alt` VARCHAR(128) DEFAULT NULL,
`typeid` TINYINT(3) UNSIGNED NOT NULL DEFAULT '1',
PRIMARY KEY (`bannerid`),
UNIQUE KEY `src` (`src`),
KEY `href` (`href`,`typeid`)
) TYPE=MyISAM;
INSERT INTO tbl_d_banner VALUES
("1","image/bigbanner01.jpg","http://big.company1.com","Text For Big Banner 1","1");
INSERT INTO tbl_d_banner VALUES
("2","image/bigbanner02.jpg","http://big.company2.com","Text For Big Banner 2","1");
INSERT INTO tbl_d_banner VALUES
("3","image/bigbanner03.jpg","http://big.company3.com","Text For Big Banner 3","1");
INSERT INTO tbl_d_banner VALUES
("4","image/bigbanner04.jpg","http://big.company4.com","Text For Big Banner 4","1");
INSERT INTO tbl_d_banner VALUES
("5","image/bigbanner05.jpg","http://big.company5.com","Text For Big Banner 5","1");
INSERT INTO tbl_d_banner VALUES
("6","image/smallbanner01.jpg","http://small.company1.com","Text For Small Banner
1","2");
INSERT INTO tbl_d_banner VALUES
("7","image/smallbanner02.jpg","http://small.company2.com","Text For Small Banner
2","2");
INSERT INTO tbl_d_banner VALUES
("8","image/smallbanner03.jpg","http://small.company3.com","Text For Small Banner
3","2");
INSERT INTO tbl_d_banner VALUES
("9","image/smallbanner04.jpg","http://small.company4.com","Text For Small Banner
4","2");
INSERT INTO tbl_d_banner VALUES
("10","image/smallbanner05.jpg","http://small.company5.com","Text For Small Banner
5","2");
CREATE TABLE `tbl_d_bannertype` (
`typeid` TINYINT(3) UNSIGNED NOT NULL AUTO_INCREMENT,
`imgwidth` INT(10) UNSIGNED NOT NULL DEFAULT '0',
`imgheight` INT(10) UNSIGNED NOT NULL DEFAULT '0',
`border` TINYINT(3) UNSIGNED NOT NULL DEFAULT '0',
`typename` VARCHAR(16) NOT NULL DEFAULT '',
PRIMARY KEY (`typeid`),
UNIQUE KEY `typename` (`typename`),
KEY `typename_2` (`typename`)
) TYPE=MyISAM;
INSERT INTO tbl_d_bannertype VALUES("1","468","60","0","big");
INSERT INTO tbl_d_bannertype VALUES("2","120","120","0","small");
---------------------------------------------------
Does anyone want to port this become a Class?
*/
?>