Photo Gallery Using PHP/MySQL and jQuery

Submitted by: 
Visitors have accessed this post 40892 times.

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.


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

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

Thanks man, be blessed

thanks for your shearing

Thank you very much...


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


How I can change the size of the final image?

i need some help.

Can i resize big images when i click to display them in orginal size


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...

nice work sir

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`
`id` int( 11 ) NOT NULL AUTO_INCREMENT ,
`location` varchar( 100 ) NOT NULL ,
`caption` varchar( 100 ) NOT NULL ,
PRIMARY KEY ( `id` )

MySQL said: Documentation
#1046 - No database selected

...What can I do to fix it? I want to use this Photo Gallery so much!!

First u make database named photoupload in phpmyadmin and then u try to import the photoupload.sql file......will work 4 sure...

Add new comment

Filtered HTML

  • Web page addresses and e-mail addresses turn into links automatically.
  • You may insert videos with [video:URL]
  • Allowed HTML tags: <a> <em> <strong> <cite> <blockquote> <code> <ul> <ol> <li> <dl> <dt> <dd> <table> <tr> <td> <th> <img> <h1> <h2> <h3> <iframe> [video]
  • You can enable syntax highlighting of source code with the following tags: <code>, <blockcode>, <asp>, <c>, <cpp>, <csharp>, <css>, <html4strict>, <java>, <javascript>, <mysql>, <php>, <python>, <sql>, <vb>, <vbnet>. The supported tag styles are: <foo>, [foo].
  • Lines and paragraphs break automatically.

Plain text

  • No HTML tags allowed.
  • Lines and paragraphs break automatically.
This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.