1 / 21

PHP MySQL Image Gallery

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. And the visitor page contain these :. Display Album List Display Image List Display Image Detail.

leon
Download Presentation

PHP MySQL Image Gallery

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

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 : • ALBUM_IMG_DIR, GALLERY_IMG_DIRThese are the absolute path to the images directories • THUMBNAIL_WIDTHThe 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. • <?phpif (function_exists('imagecreate')) {   echo 'OK, you already have GD library installed';} else {   echo 'Sorry, it seem that GD library is not installed/enabled';}?>

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

  12. Logout.php <?php require_once '../library/config.php'; // To logout we only need to set the value of isLogin to false $_SESSION['isLogin'] = false; header('Location: login.php'); exit; ?>

  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

More Related