View Single Post
Old 07-17-2005, 01:47 AM   #8 (permalink)
jaswinder_rana
The Acquainted
 
Join Date: May 2005
Posts: 106
Thanks: 0
jaswinder_rana is on a distinguished road
Default

one more suggestion,
you can just put all the iamge names in array and then it can spare you one more step, which is a big switch statement. like this
PHP Code:
<?php
$imageArr 
= array('ban1.gif','ban2.jpg','ban3.gif');
$iamgeCount count($imageArr);
srand(time());
$rand rand(0,($imageCount-1));//0-2 in this case
echo '<img src = "'.$imageArr[$rand].'" width="150" height="150"  />';
?>
and to make it more easy, you can make it read adirectory and store all the image names in an array and then use that array,

this will give you flexibility like,
in the first method, you can put any number of images in array
in second, just put images in directory and it'll automatically pick them up.

and ofcourse, using database is a totally different option

hope this helps
__________________
---------------------------
Errors = Improved Programming.
Portfolio
Send a message via MSN to jaswinder_rana
jaswinder_rana is offline  
Reply With Quote