How to Load mySQL data in Flash using PHP?
Now let us learn how to display data from mySQL database through PHP in a flash file.
Follow these steps.
1) Create a PHP page with the following code to get the data from your database...
2) Create an SWF file named �test.swf�.
3) Create a text box to display your dynamic content from mySQL in your SWF.
4) Assign a variable named 'content' in your SWF. Make sure to use the same variable in your PHP page (see the code given below)
5) Include your SWF file in your PHP page.
Code the PHP page as given below.
Change the flash SWF details in your php file as given below.
The 'content' is the same variable that you set in your flash file for the dynamic content. If you have done all as above, your mySQL data should display in your SWF file on your PHP page.
Hope this article will help you. Please post your comments.
Follow these steps.
1) Create a PHP page with the following code to get the data from your database...
2) Create an SWF file named �test.swf�.
3) Create a text box to display your dynamic content from mySQL in your SWF.
4) Assign a variable named 'content' in your SWF. Make sure to use the same variable in your PHP page (see the code given below)
5) Include your SWF file in your PHP page.
Code the PHP page as given below.
| Code: |
| <?php
$db_name="dev";// Database name $connection=mysql_connect("localhost","root","") or die("I couldn't connect"); $db=mysql_select_db($db_name) or die("I couldn't select your database"); $sql = "SELECT content FROM contents WHERE id = $id"; $result = mysql_query($sql, $connection); $row = mysql_fetch_array($result); $content = $row['content']; ?> |
Change the flash SWF details in your php file as given below.
| Code: |
<object codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflas h.ca b#version=6,0,29,0" width="550" height="400">
<embed src="test.swf?content=? echo $content ?>" " quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="550" height="400"></embed></object>
The 'content' is the same variable that you set in your flash file for the dynamic content. If you have done all as above, your mySQL data should display in your SWF file on your PHP page.
Hope this article will help you. Please post your comments.
Commentaires
Enregistrer un commentaire