[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

html insert swf in mysql

Posted on 2009-12-29
3
Medium Priority
?
517 Views
Last Modified: 2013-12-12
Is it possible to have html coding that embeds a swf file, and coding is in a field in a mysql database table and then have php code pull that code to insert the swf in a specific table in the html document..

i know that sounds weird..
but i have some ads that are  made in flash but i do not want them to show on every html page this way i can regulate what swf shows up where...

0
Comment
Question by:chefkeifer
3 Comments
 
LVL 3

Accepted Solution

by:
ad4m1 earned 2000 total points
ID: 26142817
You can do yes.
You'll need to write a php script to access a table where you'll store the SWF files as a BLOB object. You can upload the SQF files into the database using the MySQL Query Browser but first you;ll need to create the table.
For example the table will have the following fields
AdvertID as Integer
AdvertData as BLOB
Then all you need to do is write a script to pull the swf data out of the AdvertData field and output it directly using the echo command:
For example:
<?php
header("Content-Type: application/ x-shockwave-flash");
$ID=mysql_real_escape_string($_GET['ID']);
$strsql="SELECT AdvertData from Adverts WHERE AdvertID=$ID;";
$rs=mysql_query($strsql);
$data=@mysql_fetch_array($rs);
echo $data['AdvertData'];
?>
You then call this script using the normal markup for a flash file and pass the source file as "<filename of your script>.php?ID=<the id of your advert>"
For exmaple:
<object width="550" height="400">
<param name="movie" value="myphpscript.php?ID=123">
<embed src="myphpscript.php?ID=123" width="550" height="400">
</embed>
</object>
Obviously this will only pull out 1 flash file so if you wante to diaply a list of all adverts then you will need to create a page with a select query to pull out all the adverts and then cycle through each one outputting the code above for each one.
For example:
<?php
$strsql="SELECT * FROM Adverts";
$rs=mysql_query($strsql);
print("<table>");
while($data=@mysql_fetch_array($rs))
   {
   print("<tr><td>Advert ID = {$data['AdvertID']}</td>");
   print("<object width=\"550\" height=\"400\"><param name=\"movie\" value=\"myphpscript.php?ID={$data['AdvertID']}\"><embed src=\"myphpscript.php?ID={$data['AdvertID']}\" width=\"550\" height=\"400\"></embed></object>");
   print("</td></tr>");
   }
print("</table>");
?>
I hope this helps. I use something very similar for outputing uploaded pictures on a couple of my customers websites. SWF files or any other imbeddable objects are no different when working with these methods.
0
 
LVL 10

Expert Comment

by:mstrelan
ID: 26143339
I don't think the question specifically wants to store the swf in the database... just the embed code to call the swf file?
0
 
LVL 15

Expert Comment

by:Insoftservice
ID: 26143486
hi,

in db make a column say suppose "swfcode"  with datatype as "mediumtext"

store the embedded code in it. i suppose u might be knowing embedded code of swf.

select swfcode from table ;

here we will get embedded code of swf.

now use this code wherever u want

Please note its an logic.


 
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Finding original email is quite difficult due to their duplicates. From this article, you will come to know why multiple duplicates of same emails appear and how to delete duplicate emails from Outlook securely and instantly while vital emails remai…
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
In this tutorial viewers will learn how to style a corner ribbon overlay for an image using CSS Create a new class by typing ".Ribbon":  Define the class' "display:" as "inline-block": Define its "position:" as "relative": Define its "overflow:" as …
In this tutorial viewers will learn how to embed Flash content in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <object> tag to embed Flash content.: To specify that the object is Flash content, d…
Suggested Courses
Course of the Month20 days, 7 hours left to enroll

867 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question