Jump to content

Display a SWF


SleepTight

Recommended Posts

Hello. I am not entirely certain if this is even possible, but I don't see why it wouldn't.

 

 

The document that I have is:

<?php 
include('../connection.php'); 
$query="SELECT * FROM projects";
$result=mysql_query($query); 
                          
        echo "<table border='1' cellpadding='10'>";  
      
        while($row = mysql_fetch_array( $result )) { 
                 
           
                echo "<tr>"; 
                echo "<td>$row[id]</td>"; 
                echo "<td>$row[name]</td>"; 
                echo "<td>$row[text]</td>";  
			echo "<td><img src='../uploads/$row[image]'/></td>";
                echo "<td><a href='editprojects.php?id=$row[id]'>Edit</a></td>"; 
                echo "<td><a href='deleteprojects.php?id=$row[id]'>Delete</a></td>"; 
                echo "</tr>";  
        }  
        echo "</table>"; 
	mysql_free_result($result);
	mysql_close($connection);
?> 

 

 

 

Basically, the only important line from that file is:

		echo "<td><img src='../uploads/$row[image]'/></td>";

 

What I am doing is uploading images and other files to a PHP database.

 

[image] = carries all the uploaded files.

 

That single line shows every uploaded image in a row. But it doesn't show the SWF because obviously 'img src' isn't for swf's.

 

Is it possible to add another code to THAT LINE to show the swf's? that single bit needs to be able to read images and swf's,

 

 

Please help if you can.

 

Link to comment
https://forums.phpfreaks.com/topic/220643-display-a-swf/
Share on other sites

Well you can simply test whether its an SWF or not, and if it use embed code instead of img src, example:

function getFileExt($filename)
{
	$fileExt = strrpos($filename, ".");
	$fileExt = substr($filename, $fileExt+1, strlen($filename)-$fileExt);
	return $fileExt;
}

 

Then in your code you can use something like:

if (getFileExt($row[image])==swf) {
echo "<td>embed blah blah .swf</td>";} else {
echo "<td><img src='../uploads/$row[image]'/></td>";

Link to comment
https://forums.phpfreaks.com/topic/220643-display-a-swf/#findComment-1142880
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.