how to echo banner (both flash & image)

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
adsegzy
Forum Contributor
Posts: 184
Joined: Tue Jul 28, 2009 9:26 am

how to echo banner (both flash & image)

Post by adsegzy »

My members that want to advert may upload their banner advert in any of the below format jpg, gif, png & swf. Am having problem echoing out my banners. I can't echo either image or flash with a code, am only able to echo out banners in jpg, gif and png with the below code;

Code: Select all

<?php
$getad=mysql_query("SELECT * FROM $table_name ORDER BY RAND() LIMIT 1");
while($rows=mysql_fetch_array($getad)){
$banner=$rows[banner];
}

echo "<img src='../$banner_folder/$banner'>";
?>
but it doesn't work for flash banners. am only able to echo flash banner with the below code

Code: Select all

<?php
$imglist='';
$img_folder = "images/";
mt_srand((double)microtime()*1000);
$imgs = dir($img_folder);
while ($file  = $imgs->read()) {
if (eregi("swf", $file)) $imglist .= "$file "; }
closedir($imgs->handle);
$imglist = explode(" ", $imglist);
$no = sizeof($imglist)-2;
$random = mt_rand(0, $no);
$image = $imglist[$random];
echo '<embed src="'.$img_folder.$image.'" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="100" height="100"></embed>';
?>
But i need a code that can display the banner irrespective of its format. pls help.
Post Reply