Quick Search:
Oracle PL/SQL Code Library
Find Or Post Oracle Jobs
Oracle Discussion & Chat
 PHP Code: Random banner picker Jump to:  
Category: >> PHP Code >> Random banner picker Bookmark and Share

<< lastnext >>

Snippet Name: Random banner picker

Description: Automatic banner rotation. Randomly selects a banner for display.

Also see:
» Random Image from Directory
» Generate random string
» Rounded random numbers
» Random Pronounceable Passwords
» Pick Randomly from Array
» Weighted Random Choice

Comment: (none)

Language: PHP
Highlight Mode: PHP
Last Modified: March 16th, 2009

/*  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( "."); 
                IF  (SUBSTR($entry,0,6)  ==  "banner") 
                                $array[$i++]  =  $entry; 
/*  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]"  ); 

Oracle Magazine
and Oracle White Papers

SQL University.net courses meet the most demanding needs of the business world for advanced education in a cost-effective manner. SQL University.net courses are available immediately for IT professionals and can be taken without disruption of your workplace schedule or processes.

Compared to traditional travel-based training, SQL University.net saves time and valuable corporate resources, allowing companies to do more with less. That's our mission, and that's what we deliver.

Click here to find out more
Home      :      Code Library      :      Sponsors      :      Privacy      :      Terms of Use      :      Contact Us 33 users online    © 2009 psoug.org

Forgot your password?