Presentation is loading. Please wait.

Presentation is loading. Please wait.

PHP MySQL Image Gallery. The admin section contain the following : Add New Album Album List Edit & Delete Album Add Image Image List Edit & Delete Image.

Similar presentations


Presentation on theme: "PHP MySQL Image Gallery. The admin section contain the following : Add New Album Album List Edit & Delete Album Add Image Image List Edit & Delete Image."— Presentation transcript:

1 PHP MySQL Image Gallery

2 The admin section contain the following : Add New Album Album List Edit & Delete Album Add Image Image List Edit & Delete Image

3 And the visitor page contain these : Display Album List Display Image List Display Image Detail

4 Now, before we go straight to the codes we need to talk about the database design, directory layout, and configurations.

5 Database Design CREATE TABLE tbl_album ( al_id INT NOT NULL AUTO_INCREMENT, al_name VARCHAR(64) NOT NULL, al_description TEXT NOT NULL, al_image VARCHAR(64) NOT NULL, al_date DATETIME NOT NULL, PRIMARY KEY(al_id) );

6 CREATE TABLE tbl_image ( im_id INT NOT NULL AUTO_INCREMENT, im_album_id INT NOT NULL, im_title VARCHAR(64) NOT NULL, im_description TEXT NOT NULL, im_type VARCHAR(30) NOT NULL, im_image VARCHAR(60) NOT NULL, im_thumbnail VARCHAR(60) NOT NULL, im_date DATETIME NOT NULL, PRIMARY KEY(im_id) );

7 Directory Layout

8 The images directory is where we kept all of the images. The image icons are stored in the thumbnail sub-directory uder the gallery. Please remember to set write access to the album, gallery, and thumbnail directories otherwise the gallery script will not be able to save the images.

9 Config.php Source : Open config.doc There are some constants in the config file that you should change :config file  ALBUM_IMG_DIR, GALLERY_IMG_DIR These are the absolute path to the images directories  THUMBNAIL_WIDTH The PHP script will create a thumbnail ( icons ) for each image that you upload. In addition when you add an album image that image will also resized automatically.

10 One more note. If you want to test this gallery on your own computer please make sure you already have GD library installed. To check if GD library is installed on your system save the following code and run it.

11 Image Gallery Administration Page Login Source : open login.doc

12 Logout.php

13 Admin Page Layout Source : open admin-index.php

14 Admin : Add New Album This is a very simple form where you can enter the album name, description and image. After you click the "Add Album" button the script will do the followings :  Save the album image, resize it if necessary  Save the album information to database

15 Interface add new album Source : open add-album.doc

16 Admin : Album List

17 Modify & Delete Album Source : open modify-album.doc

18 Delete Album The code for deleting an album is located in the index.php file. The code flow is like this :  Get the album id  Make a query to get the name of that album and the thumbnail filename. Print an error message if the album doesn't exist  If the album exist get images file name and delete the images plus the album icon  Delete the album data and the images from the database

19 Source delete : lihat admin-index.doc //... some code on top if (isset($_GET['deleteAlbum']) && isset($_GET['album']) ) { $albumId = $_GET['album']; // get the album name since we need to display // a message that album 'foo' is deleted $result = mysql_query("SELECT al_name, al_image FROM tbl_album WHERE al_id = $albumId")

20 Album List

21


Download ppt "PHP MySQL Image Gallery. The admin section contain the following : Add New Album Album List Edit & Delete Album Add Image Image List Edit & Delete Image."

Similar presentations


Ads by Google