|
|
|
|
|
This code can de used to select a random image from any directory. You can use the code for creating a banner selector also.
| <?
$dir=opendir("/path/to/your/images/folder/");
$i=0;
while($imgfile=readdir($dir))
{
if ($imgfile != "." && $imgfile!="..")
{
$imgarray[$i]=$imgfile;
$i++;
}
}
closedir($dir);
$rand=rand(0,count($imgarray)-1);
if($rand >= 0)
{
echo '<img src="../images/gallery/'.$imgarray[$rand].'" width="170" height="137">';
//replace path, width & height sizes to fit your needs
}
?> | | |
|
| Convert a File database into MySQL Categories : PHP, Filesystem, Databases, MySQL, Beginner Guides | | | Introduction to Language Files Categories : PHP, Filesystem, Beginner Guides | | | A flat file counter Categories : PHP, Cookies, Filesystem, Beginner Guides | | | PHP based Contact email form with multiple recipients, text file based, supports departments. Categories : PHP, Email, Beginner Guides, Filesystem | | | Link Submition - Allow your visitors to submit links to the site. Categories : PHP, Arrays, Filesystem, Beginner Guides | | | Creating a Language File Categories : PHP, Beginner Guides, Filesystem | | | Simple image counter Categories : PHP, Graphics, Filesystem, Beginner Guides | | | Selecting a random line from a text file Categories : PHP, Filesystem, Arrays, Beginner Guides | | | My Box - PHP Class that calculates the volumetric weight of a package.
Categories : PHP, Object Oriented, PHP Classes, Beginner Guides, Payment Gateways | | | for each record, do this to the first record, and do that to any subsequent record Categories : PHP, Databases, MySQL, Beginner Guides | | | Current Page's URL using PHP Categories : PHP, Beginner Guides, Global Variables | | | Remote File Size Categories : PHP, Filesystem, HTTP, Sockets | | | Fetching product details from the commission junction website using php Categories : PHP, FTP, Filesystem, Compression | | | Newbie Notes #5 - To double quote, or single quote, that is the question Categories : PHP, Beginner Guides, Variables | | | Quote For the Day Categories : PHP, Utilities, Filesystem | |
| |
| | | | | Jose Santos wrote :1327
This example is very useful in web interfaces.
Its very good !!
| |
|
|