Reply to Re: happy new year with a simpleton question...

Your name:

Reply:


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]

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация