|
Follow @phpsnips |
<?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++;
}
?>
|
Rate this Snippet: |
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
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)
2011-06-29 04:00:03