Using PHPMyAdmin and a Simple Example of creating a Flash Database app
The following exercise's work through creating a table, using PHP to access that table and building a Flash Client For the User Interface.
First Create a New Database: In the Text field just beneath 'Create a new database' on the main page enter FlashTest. Then click 'Create'. You should get a message such as 'Database FlashTest has been created'.
Next where going to create a table. On the current screen find where it says "Create new table on database FlashTest" - then for the Name call it "news". For the amount of Fields enter "4".
On the next screen you'll see something that looks like a table. Fill it out as following by selecting items from the drop down menu, or typing them into the fields - only the columns that where using where included:
| Field | Type | Value | Extra | (other) |
| ID | INT | auto_increment | Check primary key | |
| UserName | Varchar | 30 | ||
| News | Text | |||
| TimeAdd | Date |
That's all you'll need for our first table. After you've entered that click 'Save'. After that you should come to a new screen and the message "table News has been created" should be up top. You've just created your first table with PHPMyAdmin!
CREATE TABLE news ( ID int(11) NOT NULL auto_increment, UserName varchar(30) NOT NULL default '', News text NOT NULL, TimeAdd date NOT NULL default '0000-00-00', PRIMARY KEY (ID) )
Now what can we do with this table. Well first where going to write two scripts and a small flash movie so that we can work with this table we just created. The two scripts consist of your 'Middle Layer' that act as a messenger between your flash client and the MySQL database you have just created.
Building the Flash Client: (All example files come with the download). Since this tutorial has already taken a while - the Actual Flash client was included in the download and will not be covered here in great detail. The main parts to it consist of 1 text area called: News. Where you News will be loaded to from the database. And two other text fields called 'UserName' and 'EnterNews'. Their is also one button. What this will do is just a small example of selecting and inserting data from/into a MySQL database. On the 'Add News' button their is the following Actionscript: loadVariablesNum("AddNews.php","0","POST"); This handles adding/inserting a new record into the database. Their is also one frame action that loads the current news from the database: loadVariablesNum("SelectNews.php","0");
You should be able to add the 'FlashExample' folder (in the download) to your htdocs web root folder and have everything working right away - as long as the above steps in creating your database and table where followed above.
The AddNews.php script contained in the download will take a User Entered Name and a news Item and add it to your newly formed table (news) in the Database (FlashTest) - when the 'Add News' button is pressed.
The SelectNews.php script will Select all of the news Items currently in the table (news) in the database (FlashTest) we just created and display them in your Flash movie.
Their is also a refresh button on the Flash client that will allow you to refresh the News area after you've added a new entry.
And I think that's about it. Hopefully that small sample is at least something you can follow along with the Code in the scripts and Flash movie.
| » Level Advanced |
|
Added: 2002-05-08 Rating: 9 Votes: 108 |
| » Author |
| Jeffrey Hill is a freelance web developer from Boulder, Colorado. He specializes in creating and developing dynamic database driven Flash content, applications, and content management systems. Specialty's include SQL, PHP, Perl, XML, web services, and Flash clients for web services. |
| » Download |
| Download the files used in this tutorial. |
| Download (30 kb) |
| » Forums |
| More help? Search our boards for quick answers! |
-
You must have javascript enabled in order to post comments.


Comments
There are no comments yet. Be the first to comment!