![]() |
Banner rotator...
any fast solution pls?
|
I have a fairly simple one I use across a bunch of my sites. Uses a 3 table database (banners, links, sites).
Pretty easy to modify out. Database structure -- -- Table structure for table `banners` -- CREATE TABLE IF NOT EXISTS `banners` ( `id` int(10) NOT NULL auto_increment, `site` int(10) NOT NULL default '0', `name` varchar(254) NOT NULL, `type` char(2) NOT NULL, `width` int(10) NOT NULL default '0', `height` int(10) NOT NULL default '0', `last_used` datetime NOT NULL, `active` tinyint(4) NOT NULL default '1', PRIMARY KEY (`id`), KEY `last_used` (`last_used`), KEY `width` (`width`), KEY `height` (`height`), KEY `site` (`site`) ) ENGINE=INNODB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1406 ; -- -------------------------------------------------------- -- -- Table structure for table `links` -- CREATE TABLE IF NOT EXISTS `links` ( `id` int(10) NOT NULL auto_increment, `site` int(10) NOT NULL default '0', `link` varchar(254) NOT NULL, `active` tinyint(4) NOT NULL default '1', PRIMARY KEY (`id`), KEY `site` (`site`) ) ENGINE=INNODB DEFAULT CHARSET=latin1 AUTO_INCREMENT=83 ; -- -------------------------------------------------------- -- -- Table structure for table `sites` -- CREATE TABLE IF NOT EXISTS `sites` ( `id` int(10) NOT NULL auto_increment, `sponsor` int(10) NOT NULL default '0', `name` varchar(35) NOT NULL, `active` tinyint(1) NOT NULL default '1', PRIMARY KEY (`id`), KEY `sponsor` (`sponsor`) ) ENGINE=INNODB DEFAULT CHARSET=latin1 AUTO_INCREMENT=75 ; Actual banner rotation code // pass ins // Type sc=softcore, hc=hardcore // mxw maximum width in pixels // mxh maximum height in pixels // mnw minimum width in pixels // mnh minimum height in pixels function getad($type, $mxw, $mxh, $mnw, $mnh) { $adbhost = "localhost"; $adbuser = "dbusername"; $adbpass = "dbpassword"; $adb = mysql_connect($adbhost, $adbuser, $adbpass); $sql_str="select a.id, a.name, c.name as sitename, a.height, a.width, b.link "; $sql_str .="from banners a "; $sql_str .="inner join links b on a.site=b.site "; $sql_str .="inner join sites c on a.site=c.id "; $sql_str .="where a.type='" . $type . "' "; $sql_str .="and a.width<=" . $mxw . " and a.height<=" . $mxh . " and "; $sql_str .="a.width>=" . $mnw . " and a.height>=" . $mnh . " "; $sql_str .="order by a.last_used limit 1"; $result=mysql_query($sql_str,$adb); if(!$result) { //echo "sql prob sql=" . $sql_str . "<br>\n"; } else { $banner=mysql_fetch_array($result); echo "<a href=" . $banner['link'] . " target=_blank>"; echo "<img src=http://www.yourdomainname.com/images/" . $banner['name'] . " border=0" . ' alt="' . $banner['sitename'] . '">'; echo "</a>"; } $sql_str="update banners set last_used=now() where id=" . $banner['id']; $result=mysql_query($sql_str,$adb); } How to call it in the page. getad('sc',480,80,350,50); |
stick a load of banners in a directory and pull 1 at random?
|
Cool thread, keep 'hem coming cause i wanna try a new one too.
|
thanks!!!!!
|
Smart Spots from Smart-Scripts.com?
|
|
PHP Code:
|
|
This is one of the most basic and user friendly HTML rotators ever, it's free as well
http://www.focalmedia.net/htmlrotate.html |
Fuck. When I was sanitizing the code I some how killed a couple of things.
Need a select to the database, or in the sql the database could be specified. Also there are a couple of other things that should be in there to protect it a touch. Sorry about that. a better version of the actual script portion: Code:
// pass ins |
Someone posted this Simple Banner Rotator on another thread and I've using it. It's pretty easy to set up and works real well.
http://www.spyka.net/scripts/javascr...banner-rotator |
i made/posted this not long ago
fucking-around-and-business-discussion/992905-simple-smart-banner-rotation-tutorial-ghetto-openx.html |
this is cool ;)
|
Quote:
|
PHP Code:
|
small - javascript
big - php (+mysql) custom huge - openx if you need any extra help http://www.awmzone.com/services |
Funny I was just looking for one yesterday as well!
Quote:
|
All times are GMT -7. The time now is 07:45 AM. |
Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
©2000-, AI Media Network Inc123