Wednesday, April 17, 2013

Image Display Randomly Using rand function

Image Display Randomly Using rand function 


<html>
<body>
<?php
srand ( microtime( ) * 100000 );
$num=rand ( 1 ,6 );
switch ( $num )
{
case 1 : $image_file ="/mahesh/1.jpg";
             break;
case 2 : $image_file = "/mahesh/2.jpg";
             break;
case 3 : $image_file = "/mahesh/3.jpg ";
            break;
case 4 : $image_file = "/mahesh/4.jpg ";
            break;
case 5 : $image_file = "/mahesh/5.jpg ";
            break;
case 6 : $image_file = "/mahesh/6.jpg ";
            break;
}
echo " Random Image :<img src=$image_file />"
?>
</body>
</html>

No comments:

Post a Comment