|
Posted by Michael on 01/01/06 12:42
Ok, first of all I think you are going about this the wrong way. First
of all I think we should put the names of the pictures into an array,
so mine will be car.jpg, cat.gif and cow.png.
[code]
<?php
$picture_array = array("car.jpg","cat.gif","cow.png");
?>
[/code]
Ok so now the script knows the names of the files we may display. We
need to make the script generate a random number now and put it into a
variable. So.....
[code]
<?php
$picture_array = array("car.jpg","cat.gif","cow.png");
$rand_no = rand(0,3);
?>
[/code]
Finally the script must render its data into (X)HTML. So...
[code]
<?php
$picture_array = array("car.jpg","cat.gif","cow.png");
$rand_no = rand(0,3);
echo "<img src=\"".$picture_array[$rand_no]."\" />";
?>
[/code]
Navigation:
[Reply to this message]
|