A while back (coupla years), my old boss created this code for me.
Code: Select all
<?
$imagetopcount='1';
$dir="ads/top_rotator";
$webpath="ads/top_rotator";
if (is_dir($dir)) {
if ($dh = opendir($dir)) {
while (($file = readdir($dh)) !== false) {
if ("$file"!="." && "$file"!="..") {
srand((float) microtime() * 10000000);
$image[$imagetopcount]="$webpath/$file";
$imagetopcount=$imagetopcount + 1;
}
}
closedir($dh);
}
}
$rn = array_rand($image);
echo "<div align=\"right\"><img src=\"$image[$rn]\" width=\"331\" height=\"185\"></div>";
?>The problem comes in when i try to run the script twice on one page. The second script is adjusted to select a picture from a different folder, as follows.
Code: Select all
<?
$imagetopcount='1';
$dir="ads/vert_ad_160x300";
$webpath="ads/vert_ad_160x300";
if (is_dir($dir)) {
if ($dh = opendir($dir)) {
while (($file = readdir($dh)) !== false) {
if ("$file"!="." && "$file"!="..") {
srand((float) microtime() * 10000000);
$image[$imagetopcount]="$webpath/$file";
$imagetopcount=$imagetopcount + 1;
}
}
closedir($dh);
}
}
$rn = array_rand($image);
echo "<div align=\"right\"><img src=\"$image[$rn]\" width=\"160\" height=\"300\"></div>";
?>I am not a newb, but i am not real proficient in PHP yet, and could really use some help. I have been lurking for a while, and can find my answers most of the time, and have learned a lot from everybodys post, so thanks!
Any help on this piece of code would be a great help!!
Thanks