PDA

View Full Version : How to toggle with flash swf and jpg image



vineet
10-29-2008, 01:09 PM
hi all

I have to scripts. One script displays the image and other script displays swf file. But both the image and swf are to displayed at the same location. so i want to toggle them.
If the user uploads an image then image should displayed as image, else if the user uploads an swf file then the swf file should be displayed.

here is my script that displays image


<?php

$qry="select * from special_offers where location='right side'";
$result = mysql_query($qry);
if(mysql_num_rows($result)>0)
{
while($row=mysql_fetch_array($result))
{

echo "<td>". "<img height=200 width=250 src='uploads/" . $row['offer_image'] . "'/>" . "</td>";

}
}
?>


Here is my script that displays swf file


<?php

$qry="select * from special_offers where location='right side'";
$result = mysql_query($qry);
if(mysql_num_rows($result)>0)
{
while($row=mysql_fetch_array($result))
{

echo "<td>";
echo "<object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0' width='250' height='200'>";
echo "<param name='movie' value='uploads/" . $row['offer_image'] ."'/>";
echo "<param name='quality' value='high' />";
echo "<embed quality='high' pluginspage='http://www.macromedia.com/go/getflashplayer' type='application/x-shockwave-flash' width='250' height='200' src='uploads/" . $row['offer_image']."'>" . "</embed>";
echo "</object>";
echo "</td>";

}
}


?>


how can i toggle them. i dont want to detect flash player. just display the image or swf according to the user input.

vineet

maneetpuri
10-31-2008, 12:39 PM
Hi,

Since you have name of the image or flash to be displayed stored in the database, thus just before displaying the same check for the extension (last four characters from string with name of media to be displayed), check if the extension is .gif or .jpg then use img src for showing the image and if its .swf then use the object tag to show it.

Hope it makes sense!

Cheers,

~Maneet
LeXolution IT Services
Web Development Company (http://www.lexolutionit.com)

vineet
11-01-2008, 03:58 AM
Hi,

Since you have name of the image or flash to be displayed stored in the database, thus just before displaying the same check for the extension (last four characters from string with name of media to be displayed), check if the extension is .gif or .jpg then use img src for showing the image and if its .swf then use the object tag to show it.

Hope it makes sense!

Cheers,

~Maneet
LeXolution IT Services
Web Development Company (http://www.lexolutionit.com)

hi maneet

thanks for the reply. can u send me some code idea or example to check extension.

or will it be done with


<?php
if($_FILES['filename']['type'] == "images/gif")
{
echo "<td>". "<img height=200 width=250 src='uploads/" . $row['offer_image'] . "'/>" . "</td>";
}
else
{
echo flash code
}
?>


vineet