SleepTight Posted December 4, 2010 Share Posted December 4, 2010 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. Quote Link to comment Share on other sites More sharing options...
Zurev Posted December 4, 2010 Share Posted December 4, 2010 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>"; Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.