PDA

View Full Version : Seeking help with randomly displaying html


AshleyQuick
01-10-2005, 05:42 PM
Can someone assist with a random php script? I have 3 logos/images I wish to display in a random fashion (I need all of them to be displayed, not just one at a time)

Here's what I have thus far (I realize I may have butchered it but I'm still learning php...be gentle!)

<?php
$images=array( "/images/img_logos/adopt_highway.gif","/images/img_logos/meals_on_wheels.gif","/images/img_logos/believe_in_tomorrow.gif" );
srand(time());
shuffle($images);
for ($i=0;$i<1;++$i) // display my images
echo "<p><a href='http://www.virginiadot.org/infoservice/prog-aah-default.asp'><img align='absmiddle' src='image $i' alt='' width='124' height='50' border='0'></a></p>";
echo "<p><a href='http://www.mowaa.org/'><img align='absmiddle' src='image $i' alt='' width='124' height='50' border='0'></a></p>";
echo "<p><a href='http://www.dreamsurfer.org/'><img align='absmiddle' src='image $i' alt='' width='124' height='50' border='0'></a></p>";
?>

Thanks,
Ash

devinemke
01-10-2005, 07:25 PM
$images = array(
'virginiadot.org/infoservice/prog-aah-default.asp|adopt_highway.gif',
'mowaa.org|meals_on_wheels.gif',
'dreamsurfer.org|believe_in_tomorrow.gif'
);

shuffle($images);

foreach ($images as $value)
{
$explode = explode('|', $value);
echo '<p><a href="http://www.' . $explode[0] . '"><img src="/images/img_logos/' . $explode[1] . '" border="0" width="124" height="50" align="absmiddle"></a></p>';
}

AshleyQuick
01-10-2005, 08:48 PM
That works great, thanks!