Logo
PHP and JavaScript Popup Image
Online Now: 2
Snippet Code
This uses JavaScript a PHP to create a pop up box to display a larger version of an image.

view_images.php


<?php
//Get all the images in the database (use a WHERE clause to limit what it finds)
$sql mysql_query("SELECT * FROM database_name");
//Start A counter we will start at 1
$i 1;
//Get all the returned results, save them in an array, and loop throught the array
//to display all the returned results
while($row mysql_fetch_array($sql)){
    
//Create a list from the returned image file, and make a $width and $height variable
    
list($width$height) = getimagesize("url/to/large/image/".$row['img_file_name']);
    
//Add 30 to the returned width and height so it will fit in the popup window
    //If it still doesn't fit, change the two thirtys to a larger number.
    
$width += 30;
    
$height += 30;
    
//Use javascript to make the popup
    //Everytime the script runs through, $i will change so we can have dynamic popup window sizes
    
echo "
    <script type="
text/javascript">
        function load"
.$i."(){
            var load = window.open('url/to/large/image/"
.$row['img_file_name']."', ' ', 'scrollbars=no,menubar=no,height=".$height.",width=".$width.",resizable=no,toolbar=no,location=no,status=no');
        }
    </script>"
;
    
//This will display our thumbnail on the screen and make a link to the popup function
    //that was just created in the above javascript.
    
echo'
    <p>
        <a href="javascript:load'
.$i.'()">
        <img src="url/to/thumb/image/'
.$row['img_file_name'].'" />
        </a>
    </p>'
;
    
//Add one to $i
    
$i++;
}
?>
 
Snippet Comments

Add Your Comment

medical assistant salary
2011-06-29 04:00:03
I certainly enjoyed the way you explore your experience and knowledge of the subject! Keep up on it. Thanks for sharing the info
dental assistant salary
2011-06-29 03:04:31
These kind of post are always inspiring and I prefer to read quality content so I happy to find many good point here in the post
EMT training
2011-06-29 02:08:00
These kind of post are always inspiring and I prefer to read quality content so I happy to find many good point here in the post
cushion manufacturers
2011-06-28 05:11:43
It is a very informative and useful post thanks it is good material to read this post increases my knowledge
solid wood worktops
2011-06-28 03:41:57
I certainly enjoyed the way you explore your experience and knowledge of the subject! Keep up on it. Thanks for sharing the info
hypnosis sheffield
2011-06-28 01:58:43
These kind of post are always inspiring and I prefer to read quality content so I happy to find many good point here in the post
ASO EVO brace
2011-06-22 15:52:18
I've been looking for this code for a couple of an hour, I am so glad that I found it here.
silver charms
2011-06-22 01:40:56
It was such really a great issue then.. Thanks much for sharing this buddy.
Orlando IT
2011-06-21 18:44:01
This works so good if it is setup properly. They have done such a great job with it.
Supra For Sale
2011-06-13 23:41:42
It can noted that Chrysler has previously announced specifically last April that it would spend $1.78 billion on transmission and engine facilities, which include Marysville and Trenton plants plus some $300 million paint shop at its assembly plant in Sterling Heights and a $50 million investment in its Warren stamping and assembly complex.
beats by dre studio
2011-06-07 21:49:42
The mood is very good!
sturdy firefighter gear
2011-05-21 15:24:33
I am glad to find it. There are so many developers working on this segment but this is one of the best innovative idea ever. Thanks for sharing it here..
Dissertation Writing
2011-05-16 14:43:04
Das Buch "Mac OS X - Leopard" richtet sich an all jene, die Erfahrung mit anderen Betriebssystemen (wie Windows) haben und neu in die Leopard-Welt eintauchen wollen.
php scripts
2010-09-14 00:19:34
yeah, you rock buddy. i like this script
Sparky
2010-05-09 00:00:00
Does nothing.

Add Your Comment

 
Snippet Tools
Rate this Snippet:

Rate the difficulty level:

Request Snippet Update


Suggested Difficulty Level: Beginner
Current Score: 3.05
Total votes: 230
Total Views: 10918

Other top snippets by admin:

1. JPEG to ASCII Converter
2. Add (th, st, nd, rd, th) to the end of a number
3. Dynamic Page Content From Links
4. AJAX Quickie
5. Simple Image CAPTCHA

Search
Search for:







User Panel

User name:

Password:

Register And Post Your Own Snippets

New Snippets

1.  Shorten text and (4 of 1)

2.  file-based simple guest (0 of 0)

3.  adding an entry (0 of 0)

4.  integer to currency (1.33 of 3)

5.  Aggregate IP addresses (0 of 0)

6.  file handling (0 of 0)

7.  testing system with (0 of 0)

8.  Make an php (1 of 1)

9.  allow download in (5 of 1)

10.  redirect in 3 (0 of 0)

11.  live clock with (0 of 0)

12.  visit counter (3.5 of 2)

13.  contact form with (4 of 1)

14.  show a specific (0 of 0)

15.  The & sign (0 of 0)

16.  static variable in (0 of 0)

17.  multiplication table with (0 of 0)

18.  function with multiplicationt (0 of 0)

19.  php generated menu (0 of 0)

20.  drawing a table (0 of 0)

21.  embedded array (one (0 of 0)

22.  checks the week (0 of 0)

23.  put links on (4.5 of 2)

24.  Directory Image Gallery (0 of 0)

25.  TOS (4 of 1)

Home | Forum | Free PHP Web Hosting | Contact | Terms & Conditions |  
Donate
PHPSnips.com - ©2012 Amethyst Creative