07-17-2005, 01:47 AM
|
#8 (permalink)
|
|
The Acquainted
Join Date: May 2005
Posts: 106
Thanks: 0
|
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
|
|
|