![]() |
How to Make Image Gallery in PHP with AJAX and Light-box
Article is about making a simple yet powerful Gallery system using PHP, AJAX and Lightbox
BackgroundSome days ago i started ma new project im building our site (for the 4th time) :D Thought to do a real difference so everything i needed to code by me. Hope this will help you too. The Codehttp://imgs.g4estatic.com/php-based-...llery/gal2.jpg Let's get started. Steps:
First thing we need is to make a php script that can retrieve all the records about the images and do page breaking. Here i used to store the info in a database rather than reading directly from a folder. This makes it possible for me to add an image description. So, when i retrieve the images possibly i want to do the dynamic page breaking, adding the pages automatically so there's no mess there. First make a folder name "res" and add some pics to it. Then in your database make a new table "images" Add 3 fields, *ID [auto increment], *Img - path to the image *Desc - Description of the image After add some record to it I added 10 for the testing purposes Now the php script Make a file named view.php NOTE: I have used CSS styling here so be patient to see the CSS style after this code :D [view.php] PHP Code:
[style.css] HTML Code:
img{..... ?> HTML Code:
<html>Adding lightbox Light box is a very attrtactive feature used in many things today. In the code above you'll notice that the <img /> tag is full of other things which of course related to the lightbox. So first Download Lightbox. Now extract all the directory where you have the view.php but DONT extract the index.html. Now we have to do the linking of the Lightbox. Modify the HTML code like this: HTML Code:
<html>Now you click on images and SEE A WONDER :DD Adding AJAX AJAX(Asynchronous JavaScript and XML_) is an attractive technology ijmplemented by many popular sites. ex: in facebook the images load when browsing a Gallery without loading pages seperately. This allows easy navigation to the user. Adding AJAX is pretty much simple in our case. Make a new file called inidex.php This is the page that user first sees Heres the code for it [index.php] PHP Code:
[view.php] PHP Code:
img{ replaced with #load_area img{ VIOLAAAAAHH!!!!! DONE it You'have sucessfully made an Ajax+Lightbox+php Gallery Alter things to make it more attractive. http://imgs.g4estatic.com/php-based-...llery/gall.jpg http://imgs.g4estatic.com/php-based-...lery/gal21.jpg |
Re: How to Make Image Gallery in PHP with AJAX and Light-box
Hello ManzZup,
You have share a very useful tips to me. I was really searching this script as I developing an image gallery where this script is to used. Thanks, |
Re: How to Make Image Gallery in PHP with AJAX and Light-box
your welcome :)
please ask for any other details |
Re: How to Make Image Gallery in PHP with AJAX and Light-box
Thanks a lot.
For this knowledge. I have not tried. But I think there must be certain benefits in the future. |
Re: How to Make Image Gallery in PHP with AJAX and Light-box
Wow this is a great post. And this is very interesting and useful. I would like to work on this. Thanks for sharing it with us.
|
Re: How to Make Image Gallery in PHP with AJAX and Light-box
thank you guys :)
|
Re: How to Make Image Gallery in PHP with AJAX and Light-box
With following through your beneficail advice, I started using it but I am having a little bit problem in doing so. Some images are showing up in one browser but some got blind in the other. As you can see my Services page, where I used some of the images
Please sir help me for this at the earliest....In need of your reply at the urgent. |
Re: How to Make Image Gallery in PHP with AJAX and Light-box
i think you would be receiving problems with some older browsers [specially IE6/7] but i have tested on most of the newer ones without any prblem
can you direct me a link to check up the problem and state the browsers you were testing this on? |
| All times are GMT +5.5. The time now is 18:18. |