WeberDev.com PHP and MySQL Code

LOG IN
BEGINNER GUIDESPHP CLASSESCODE SEARCHARTICLES SEARCHPHP FORUMSPHP MANUALPHP FUNCTIONS LISTWEB SITE TEMPLATES
Start typing to search for PHP and MySQL Code Snippets and Articles Search
Submit a code Example / Snippet Join us on FaceBook
Submit a code Example / Snippet Submit Your Code
Poker Tournaments Poker Tournaments
Poker Guide for Developers Poker Guide for Developers
Search Engine Optimization Monitor SEO Monitor
Web Site UpTime Monitor UpTime Monitor
Your Personal Examples List My Favorite Examples
Your Personal Articles List My Favorite Articles
Edit Account Info Update Your Profile
PHP Code Search
Web Development Forums
Learn MySQL Playing Trivia
PHPBB2 Templates
Web Development Resources
Web Development Content
Internet Security Software
PHPClasses
PHP Editor
PHP Jobs
Vision.To Design
Ajax Tutorials
PHP Programming Help
PHP/MySQL Programming
Webmaster Resources
Webmaster Forum
XML meta language
website builder
פרייסז - הכח לקנות עובר לידיים שלך
Texas Holdem Poker Evangelists

Go Back Add a Comment Send this example to a friend Add this Article to your personal favoritest for easy future access to your favorite Code Examples and Articles. Submit a code example Print this code example.
BACK ADD A COMMENT SEND TO A FRIEND ADD TO MY FAVORITES ADD CODE EXAMPLES PRINT
Title : Automatic banner rotation. Randomly selects a banner for display.
Categories : Graphics, PHP, Complete Programs Update Picture
Anton Olsen
Date : Jan 17th 1999
Grade : 3 of 5 (graded 10 times)
Viewed : 20277
File : No file for this code example.
Images : No Images for this code example.
Search : More code by Anton Olsen
Action : Grade This Code Example
Tools : My Examples List

Submit your own code examples  Submit your own code examples 
 

<?php
/* banner.phtml
Banner rotation script for PHP3 by Anton Olsen (aolsen@graphweb.com)
Please feel free to do with this script what you want, all I ask is
that if you make significant changes, please e-mail them to me.

I tried to use a number of different methods, the image functions
of PHP do not appear to understand animated GIFs and the file
handling features (fopen, fpassthru, and fclose) were causing
apache to crash on me. I settled on using passthru. Although
possibly not as portable, it appears to work faster than either
method mentioned above.

Assumptions:
You have a directory for all your banners.
All banners are GIF files.
The filenames of the banners all start with banner.
There are no other files in the directory starting with banner.

Installation:
Place this script in the banners directory.
Place all your banner*gif files in the same directory.
Add the following HTML code to your web pages :
<a href="wherever.you.want.com">
<img src="http://www.yourserver.com/bannerdir/banner.phtml" alt="Random Banner Here" border=0>
</a>

*/

/* random( $max integer )
Returns a random number between 0 and $max-1;
*/
function random( $max )
{
$x = rand();
$y = getrandmax();

$r = $x / $y * ($max -1 );

$r = round( $r++ );
return $r;
}

/* Read the directory, add all "banner*" files with to the array
*/
$i = 0;
$d = dir( ".");
while($entry=$d->read())
if (substr($entry,0,6) == "banner")
$array[$i++] = $entry;
$d->close();


/* pick a banner at random
*/
$r = random( $i );

/* Send a no-cache header, and the gif type header, and output the file.
*/
Header( "Pragma: no-cache" );
Header( "Expires: Monday 01-Jan-80 12:00:00 GMT" );
Header( "Content-type: image/gif");
passthru( "cat $array[$r]" );

?>



a little counter-script for PHP. Needs the gd-library and Colors.php
Categories : Graphics, PHP, Complete Programs
This is a script that list all image files on a given directory, and displays the thumbnails nicely formated within an HTML table. It also make use of JavScript to open pop up windows when the users want to see the full photo.
Categories : Graphics, PHP, Complete Programs, Java Script
This is a simple photo gallery that reads the image files from multiple directories, and generates a web page styled with CSS1. It opens single auto window to view and print a given image.
Categories : Graphics, Filesystem, PHP, Complete Programs
Expose - PHP template engine, supports server and client-sided caching,a plugin system, multiple languages, template script language is based on PHP itself.
Categories : PHP, PHP Classes, Templates, Complete Programs
Finds files on your site, uses UNIX find command.
Categories : Complete Programs, Filesystem, PHP
Image Cache
Categories : Graphics, PHP Classes, PHP
Create and restore backup of MySQL databases
Categories : MySQL, Databases, PHP, PHP Classes, Complete Programs
Look for the *position* of the first occurence of string2 in string1, beginning at position start.
Categories : Complete Programs, PHP, Strings
A PHP based webmail at : http://www.horde.org/imp
Categories : Email, IMAP, PHP, Complete Programs
Rich Editor (RE) is a cross-browser WYSIWYG html editor
Categories : Content Management, Editors and IDEs, PHP, Complete Programs
Create a Thumbnail Using PHP, GD and Exif
Categories : PHP, Graphics, Exif, GD image library
Simple way of scaling any image to fit either given width or height.
Categories : PHP, Graphics, Arrays
Dynamic WHERE CLAUSE depending on number of FORM FIELDS
Categories : ODBC, General SQL, PHP, Complete Programs, Databases
ClassFuncDoc - This script is a classes and functions documentation tool.
Categories : PHP, Classes and Objects, Documentation, PHP Classes, Complete Programs
Free For All Links Page using PHP3 and Mysql
Categories : PHP, MySQL, Complete Programs
 Vincent Kruger wrote :405
Could any one maybe modify this script to select 
random html code from a mysql database instead of 
selecting a random gif froma directory.

I have tried to modify it myself, but have no come 
through.

I off to try again !
Vince