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


html insert swf in mysql

Posted on 2009-12-29
Medium Priority
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...

Question by:chefkeifer

Accepted Solution

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:
header("Content-Type: application/ x-shockwave-flash");
$strsql="SELECT AdvertData from Adverts WHERE AdvertID=$ID;";
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">
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:
$strsql="SELECT * FROM Adverts";
   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>");
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.
LVL 10

Expert Comment

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?
LVL 15

Expert Comment

ID: 26143486

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.


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