I am displaying image dynamically from database, When I click the particular image I want to show that image in a popup or lightbox in a simple way. How to do?

As I understood you serve images dynamically so you are familiar on how to serve images in other sizes as well. It alls has to do with how you store image data in your database and how you serve them. For example if serving them you resizing images in a certain scale than who ever serves them could get an argument returning the image in its original scale without resizing.

Few thoughts , I keep seeing more developers choosing to store their images data into database. It might have to do with the fear that adopting a repository system where real files lies into system and its description in db might issue problems. But this is really in the hand of the programmer to qualify. I believe that adopting a repository system is worth the effort.

A second thought is scaling images dynamically. Usually when I save an Image I save it also in its original scale (or max permitted) AND as Thumbnail. Those dimensions are kept to a different table in the repository system db tier linking to the main repository files table. In most cases the Thumbnails will be used , so having a ready made thumbnail version of the image saves a lot of computation power.

Ok Thanks to both of you but I need a sample code

Do use this fancyapp there is a demo gallery inside like the one you requested.

it is in demo folder you will find an index.html just open with sublime(any other programming software you have) you will find the codes and the java scripts also some CSS there