html insert swf in mysql

Posted on 2009-12-29
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
    LVL 3

    Accepted Solution

    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

    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


    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.


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Javascript: Crash Course

    Javascript is not only emerging as the most important language to know, it's flexibility is unique. With Javascript being deployed on the web, mobile and even the desktop this is the one language that all technologists need to know.

    This is a PowerShell web interface I use to manage some task as a network administrator. Clicking an action button on the left frame will display a form in the middle frame to input some data in textboxes, process this data in PowerShell and display…
    Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
    The viewer will learn how to count occurrences of each item in an array.
    The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…

    779 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

    Need Help in Real-Time?

    Connect with top rated Experts

    21 Experts available now in Live!

    Get 1:1 Help Now