several instances of Flash in a for -loop (with mysql involved!)

Discussion in 'PHP' started by tikitin, Sep 9, 2008.

  1. #1
    I have made an flash application, which imports data from a mysql database to choose the background picture for "myFlash.swf" and to insert certain extra elements into the picture. Everything works fine as long as I have only one flash on the page.
    But when I write a "for" -loop, wanting to have several flash pictures on the same page, I'm only getting the same instance of flash again and again. This flash is the one, which is supposed to be the last one in the "for" -loop. What I want is several instances of the same flash, each with different picture and different extra elements.

    "myFlash.swf" reads file "vars.php", which outputs the variables needed by "myFlash.swf". The temporary number "number" (in a mysql table called "temp") guides "vars.php" to the data in mysql database to the special data which is needed for this particular instance of "myFlash.swf".




    My code is like this:

    <?php
    for ($i;$i<4;$i++) {
    $sql=mysql_query("select id from myTable where pictureNumber=$i");
    $p=mysql_result($sql,0);
    mysql_query("update temp set number=$p where id=1");

    echo "<object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0' width='400' height='300' id='myFlash' align='middle'>
    <param name='allowScriptAccess' value='sameDomain' />
    <param name='movie' value='myFlash.swf' />
    <param name='quality' value='high' />
    <param name='bgcolor' value='#3333ff' />
    <embed src='myFlash.swf' quality='high' bgcolor='#3333ff' width='400' height='300' name='myFlash' align='middle' allowScriptAccess='sameDomain' type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer' />
    </object>";
    }
    ?>


    file "vars.php" goes something like this:

    <?php
    $sql=mysql_query("select number from temp where id=1");
    $number=mysql_result($sql,0);

    $sql2=mysql_query("select pictureName, extraInfo from myTable where id=$number");
    $info=mysql_fetch_row($sql2);

    $variables="pictureName=".$info[0]."&extraInfo=".$info[1];
    echo $variables;
    ?>
     
    tikitin, Sep 9, 2008 IP