FYP 2 - Programming Progress 3

After done the basic HTML layout and Flash function, I started to combine them and make the whole site dynamic with database.

First I convert all the html file to php file, created a config.php to connect to database and include in all the file.



Then I created a table called "photos" in phpmyadmin, used to store all the photos data submitted by users.


The structure for this table:

PhotoID - Unique ID for each photos, set as AUTO_INCREMENT
Name - The user's name
Description - The user's message
IsActive - To allow control for the data, which can set the photos that do not want to show as not active but no need to delete it, because maybe need it in future.
Created - The time that the data was created, using CURRENT_TIMESTAMP that can automatically use current time.


Then can started to try to insert data into the photos table.
I write the following script in the php file that integrate with the flash to create the jpg file:


When the file is accessed, the "INSERT" query insert dummy data into the photos table in the database. PhotoID as NULL because it can AUTO_INCREMENT and the main purposely is to let it generate a new id for the photos that going to save.

After insert the data, I used the "SELECT" query to get the data back to the php file, to use the PhotoID that just generated as the name for the .jpg image that going to save.

And it worked fine! So I can continue to the flash to create 2 input text for the users input.


And send the data to php file using "sendAndLoad" function in flash.


After that I get the data in php from the POST variables:


And use that variables to insert it into the database using the INSERT query justnow:


Then check the database, the data successfully inserted!



After that I need to get the data from database in the gallery page using the "SELECT" query.


and arrange the photos using css float properties so that it will arrange automatically.

No Response to "FYP 2 - Programming Progress 3"

Post a Comment