Sunday, May 18, 2008

Create Album with PHP and Database (1)

Use PHP and database to create an album consists of parts:
  1. create a table in the database
  2. write an PHP file to upload images
  3. write an PHP file to view the album
Today we just introduce how I create a table in my database.



The picture above is the structure of the table in my database.
Let's explain those parameters a little bit.
  1. id is just an index that will be auto incremented by the system but has no great significance.
  2. name is the name of the picture you store.
  3. type is the content type of that image. (e.g. jpeg, gif, or png etc..)
  4. size is the size(kB or MB) of the image.
  5. content is the image content. Note here that you have to set the attribute of this to mediumblob in order to store the image in the database.
  6. album_name is the name of the album that a picture belongs to.
  7. album_num is the tag of the the album that a picture belongs to.
  8. pic_num is the index of that picture in the album it belongs to.
  9. author is the name of the owner of that picture.
  10. width is the width of that picture.
  11. height is the height of that picture.
We will talk more about how to upload the image to the database.
Basically it is the same as you upload a text to the server.
Anyway, we will continue to discuss this in a later time.

No comments: