T14 PHP MySQL Image Gallery
-
Author
bobbo-parva -
Category
Documents
-
view
220 -
download
0
Embed Size (px)
Transcript of T14 PHP MySQL Image Gallery
-
8/6/2019 T14 PHP MySQL Image Gallery
1/21
PHP MySQL Image Gallery
-
8/6/2019 T14 PHP MySQL Image Gallery
2/21
The admin section contain the following :
Add New Album
Album List
Edit & Delete Album Add Image
Image List
Edit & Delete Image
-
8/6/2019 T14 PHP MySQL Image Gallery
3/21
And the visitor page contain these :
Display Album List
Display Image List
Display Image Detail
-
8/6/2019 T14 PHP MySQL Image Gallery
4/21
Now, before we go straight to the codes weneed to talk about the database design,directory layout, and configurations.
-
8/6/2019 T14 PHP MySQL Image Gallery
5/21
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,
PR
IMARY
KEY
(al_id));
-
8/6/2019 T14 PHP MySQL Image Gallery
6/21
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 VARCH
AR
(60) NOT NULL,im_date DATETIME NOT NULL,PRIMARY KEY(im_id));
-
8/6/2019 T14 PHP MySQL Image Gallery
7/21
Directory Layout
-
8/6/2019 T14 PHP MySQL Image Gallery
8/21
The images directory is where we kept all ofthe images. The image icons are stored inthe thumbnail sub-directory uder the gallery.Please rememberto set write access to thealbum, gallery, and thumbnail directoriesotherwise the gallery script will not be able to
save the images.
-
8/6/2019 T14 PHP MySQL Image Gallery
9/21
Config.php
Source : Open config.doc
There are some constants in the config filethat you should change :
ALBUM_IMG_DIR, GALLERY_IMG_DIRThese are the absolute path to the imagesdirectories
THUMBNAIL_WIDTH
The PHP script will create a thumbnail ( icons )for each image that you upload. In addition whenyou add an album image that image will alsoresized automatically.
-
8/6/2019 T14 PHP MySQL Image Gallery
10/21
One more note. If you want to test this gallery onyour own computer please make sure you alreadyhave GD library installed. To check if GD library isinstalled on your system save the following code
and run it.
-
8/6/2019 T14 PHP MySQL Image Gallery
11/21
Image Gallery Administration Page
Login
Source : open login.doc
-
8/6/2019 T14 PHP MySQL Image Gallery
12/21
Logout.php
-
8/6/2019 T14 PHP MySQL Image Gallery
13/21
Admin Page Layout
Source : open admin-index.php
-
8/6/2019 T14 PHP MySQL Image Gallery
14/21
Admin : Add New Album
This is a very simple form where you canenter the album name, description andimage. 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
-
8/6/2019 T14 PHP MySQL Image Gallery
15/21
Interface add new album
Source : open add-album.doc
-
8/6/2019 T14 PHP MySQL Image Gallery
16/21
Admin : Album List
-
8/6/2019 T14 PHP MySQL Image Gallery
17/21
Modify & Delete Album
Source : open modify-album.doc
-
8/6/2019 T14 PHP MySQL Image Gallery
18/21
Delete Album
The code for deleting an album is located inthe index.php file. The code flow is like this :
Get the album id
Make a query to get the name of that album andthe thumbnail filename. Print an error message ifthe album doesn't exist
If the album exist get images file name and deletethe images plus the album icon
Delete the album data and the images from thedatabase
-
8/6/2019 T14 PHP MySQL Image Gallery
19/21
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_imageFROM tbl_albumWHERE al_id = $albumId")
-
8/6/2019 T14 PHP MySQL Image Gallery
20/21
Album List
-
8/6/2019 T14 PHP MySQL Image Gallery
21/21