Search Tutorials
Using PHPMyAdmin and a Simple Example of creating a Flash Database appThe 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'. Note: Creating a database will create a Folder in
the C:\mysql\data directory. You can check to see if the folder 'FlashTest'
is their - it will be. A database is made up of individual Tables, you
can have as many tables in a database as you want. Each time you create
a Table in your database it will create 3 new files in your C:\mysql\data\FlashTest\
folder. You really don't need to know this info - but it might be
interesting to know where your data is physically being stored - that's where.
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:
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! Other items you can now do with your database: First
of all try to explore all of the options in PHPMyAdmin. You can't really
hurt anything at this point so just try everything. When your looking at
a new table you can click on 'Properties' which allows to change some of the
Fields and Type's around. You can also click on Insert - where you can
manually enter new records if needed. One Important part is a bit
further down that page where it says something like "View dump (schema)
of database" - using the options below that you can create a backup of
your database. If you dump the Structure of the database this will
create some SQL (instructions) in formatted text - this SQL can be used to
replicate/backup your database on any computer by instructing MySQL how to
re-create your database exactly as it was at the old location. For this
example is we dumped the table structure of 'FlashTest it would look something
like:
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.
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
![]() |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|