I want to know how to have a random image displayed everytime you view a page.do you have a prefered method,
client side or server side?Nope, no preference, as long as I find out how to do it <?php
$image[0]='1.jpg';
$image[1]='2.jpg';
echo '<img src=http://www.htmlforums.com/archive/index.php/"',$image[rand(0,count($image))],'">';
?>
or
<script type="text/javascript">
document.write('<img src=http://www.htmlforums.com/archive/index.php/"' + rand(2) + '.jpg">');
</script>There are pleny of scripts for this at <!-- w --><a class="postlink" href="http://www.hotscripts.com">www.hotscripts.com</a><!-- w -->
Have a look under the title of 'Image ... ' in the scripts section for each language.Server side (PHP or ASP) is better. It will then work the same for all users.
I would not rely on javascript (client side) for this.Originally posted by illogique
<?php
$image[0]='1.jpg';
$image[1]='2.jpg';
echo '<img src=http://www.htmlforums.com/archive/index.php/"',$image[rand(0,count($image))],'">';
?>
Is there something I can add to this so it doesn't display the same image twice in a row?
client side or server side?Nope, no preference, as long as I find out how to do it <?php
$image[0]='1.jpg';
$image[1]='2.jpg';
echo '<img src=http://www.htmlforums.com/archive/index.php/"',$image[rand(0,count($image))],'">';
?>
or
<script type="text/javascript">
document.write('<img src=http://www.htmlforums.com/archive/index.php/"' + rand(2) + '.jpg">');
</script>There are pleny of scripts for this at <!-- w --><a class="postlink" href="http://www.hotscripts.com">www.hotscripts.com</a><!-- w -->
Have a look under the title of 'Image ... ' in the scripts section for each language.Server side (PHP or ASP) is better. It will then work the same for all users.
I would not rely on javascript (client side) for this.Originally posted by illogique
<?php
$image[0]='1.jpg';
$image[1]='2.jpg';
echo '<img src=http://www.htmlforums.com/archive/index.php/"',$image[rand(0,count($image))],'">';
?>
Is there something I can add to this so it doesn't display the same image twice in a row?