Skip to main content

Photo Gallery Using PHP/MySQL and jQuery


This is a simple gallery using php and jquery. In this code you will learn on how to combine php and jquery to create a simple but powerful gallery. This is unique with other gallery out there because this gallery has a database. The image source of this gallery comes from the database. Download this code and try this on your own to see how php and jquery works. Leave comment if you have question and suggestion in this code, happy coding and hope this code will help you.

Note: Due to the size or complexity of this submission, the author has submitted it as a .zip file to shorten your download time. After downloading it, you will need a program like Winzip to decompress it.

Virus note: All files are scanned once-a-day by for viruses, but new viruses come out every day, so no prevention program can catch 100% of them.


1. Re-scan downloaded files using your personal virus checker before using it.
2. NEVER, EVER run compiled files (.exe's, .ocx's, .dll's etc.)--only run source code.


Submitted byAnonymous (not verified)on Thu, 01/17/2013 - 14:57

First of all, thank you for sharing this, everything seems to be great but, I'm having some troubles when I try to import the .sql file to my PhpMyadmin, it throws this: SQL query: -- -- Database: `photoupload` -- -- -------------------------------------------------------- -- -- Table structure for table `photos` -- CREATE TABLE IF NOT EXISTS `photos` ( `id` int( 11 ) NOT NULL AUTO_INCREMENT , `location` varchar( 100 ) NOT NULL , `caption` varchar( 100 ) NOT NULL , PRIMARY KEY ( `id` ) ) ENGINE = MYISAM DEFAULT CHARSET = latin1 AUTO_INCREMENT =5; MySQL said: Documentation #1046 - No database selected ...What can I do to fix it? I want to use this Photo Gallery so much!!
Submitted byAnonymous (not verified)on Thu, 01/24/2013 - 23:35

In reply to by Anonymous (not verified)

First u make database named photoupload in phpmyadmin and then u try to import the photoupload.sql file......will work 4 sure...
Submitted byAnonymous (not verified)on Thu, 01/17/2013 - 15:33

nice work sir
Submitted byAnonymous (not verified)on Thu, 02/14/2013 - 23:53

Hi, Thanks for the code, good stuff. Question: I'm allowing users to upload photos to my database. The images are stored in a longblob field called 'file_data'. My problem is how to correctly write the php code to populate the gallery with the users images. I can properly select the images from the correct user, this is not a problem, however, I don't know what to replace your 'location' with... Can you offer any advice? Thanks in advance... Ocusfend
Submitted byAnonymous (not verified)on Fri, 04/12/2013 - 20:12

Hi, i need some help. Can i resize big images when i click to display them in orginal size

i have also same problem size of final image is so large what can i do to prevent such type of problem please help me
Submitted bystudent Z (not verified)on Tue, 01/14/2014 - 15:58

thanks for your shearing
Submitted bySohan Lal (not verified)on Sat, 07/04/2015 - 14:41

you just insert picture into db manually and show them on webpage but there is major drawback is admin panel where user can add image gallery categories and ad photos in those categories from the admin panel developers can easily do work with this but the clients needs admin panel from there they just upload images and that show on page they cannot understand coding

Submitted byDomingo (not verified)on Mon, 10/12/2015 - 14:16

How could I get previous and next button funcionality on big images?

Add new comment