M.Paaske Posted July 28, 2008 Share Posted July 28, 2008 I'm trying to wright my own gallery... And I figgerd I wont a row of images in the bottem when you click one it comes up in a bigger version in the mittle on the screan... I'm geussing that can be done by a <a href="zz" target="xx"></a>, but can it realy be done and how do I get it to make that link apear on every img from the database without having to add it to every img... So I geus what i'm asking is.... Can I make a link on images that change on demand to another img from the database and link to the NEW img... Quote Link to comment https://forums.phpfreaks.com/topic/116944-gallery/ Share on other sites More sharing options...
MasterACE14 Posted July 28, 2008 Share Posted July 28, 2008 yes. quite easily actually. You'll grab the image location or whatever from the database, put it into a associative array, and then echo the database info(through the array) into HTML tags. for example: <img src="<?php echo $row['imagelocation']; ?>"></img> Regards ACE Quote Link to comment https://forums.phpfreaks.com/topic/116944-gallery/#findComment-601385 Share on other sites More sharing options...
LemonInflux Posted July 28, 2008 Share Posted July 28, 2008 If you wanted a script that immediately updates (eg you click the picture and instantly it appears bigger), then you might want to look at javascript for this. Quote Link to comment https://forums.phpfreaks.com/topic/116944-gallery/#findComment-601386 Share on other sites More sharing options...
M.Paaske Posted July 28, 2008 Author Share Posted July 28, 2008 If you wanted a script that immediately updates (eg you click the picture and instantly it appears bigger), then you might want to look at javascript for this. I wont a row of 4-5 images in the bottom of the screan and when you click one it will be linked to the center on the screan in a big version... But the bottom ones allsow have to be able to be replaced by a "Next" and "prevois" botten so that ther will apear 4-5 new img's that still works as links... Quote Link to comment https://forums.phpfreaks.com/topic/116944-gallery/#findComment-601416 Share on other sites More sharing options...
ignace Posted July 28, 2008 Share Posted July 28, 2008 <?php $num_imgs = sizeof($image_rows) - 1; $current_row = (int) $_GET['image']; $has_previous = false; $has_next = false; if ($current_row >= $num_imgs) { $current_row = $num_imgs; } else { $has_next = true; } if ($current_row <= 1) { $current_row = 1; } else { $has_previous = true; } // the image echo '<img src="' . $image_rows[$current_row]['image_path'] . '" />'; // previous echo ($has_previous ? '<a href="?image=' . $current_row . '">previous</a>' : '<b>previous</b>'); // next echo ($has_next ? '<a href="?image=' . ($current_row + 1) . '">next</a>' : '<b>next</b>'); Quote Link to comment https://forums.phpfreaks.com/topic/116944-gallery/#findComment-601489 Share on other sites More sharing options...
LemonInflux Posted July 28, 2008 Share Posted July 28, 2008 I know I'm really pushing away from PHP now, but look at this: http://www.huddletogether.com/projects/lightbox2/ ---------------- Now playing: Enter Shikari - Closing via FoxyTunes Quote Link to comment https://forums.phpfreaks.com/topic/116944-gallery/#findComment-601492 Share on other sites More sharing options...
KrisMunro Posted July 28, 2008 Share Posted July 28, 2008 It's quite simple to use an iframe to house your big image. Within the cell you want the image placed, put this: <iframe src ="/blank.html" width="100%" name="updatebox" scrolling="auto" frameborder="0"> </iframe> You can set the height and width, scrolling frameborder etc as you require. As for the image gallery: $listID = 0; $resultsID = mysql_query("SELECT imageID, thumb, location FROM images", $linkID) or die(mysql_error()); while (list($imageID, $thumb, $location) = mysql_fetch_row($resultsID)) { $imagearray["$listID"] = array('thumb'=>"$thumb", 'location'=>"$location", 'imageID'=>"$imageID"); $listID += 1; } Once the array is set up you can retrieve the images with this code: <a href="<?php print $imagearray["$number"]['location']; ?>" target="updatebox"><img scr="<?php print $imagearray["$number"]['thumb']; ?>"></a> Where you alter the $number by one each time you repeat it; perhaps with a while ($number < $totalimages) { show image, then increase $number by 1, ladeda sorta deal; But keep in mind you're starting from 0 (not 1). Hope this helps. Let me know if you wanted to include additional pages. It's fairly simple.. but if you care to try yourself, just multiply your desired image display limit (eg 5) by the page number, and start your $number from there. Quote Link to comment https://forums.phpfreaks.com/topic/116944-gallery/#findComment-601574 Share on other sites More sharing options...
M.Paaske Posted August 7, 2008 Author Share Posted August 7, 2008 Thank you, so far we've come to the point in your script where we need to select the variebles from the DB. But what variebles do we need to put in the DB? We're confused at the point where you've written "Thumb" and "Location" And again, Thank you so much ^^ Quote Link to comment https://forums.phpfreaks.com/topic/116944-gallery/#findComment-610661 Share on other sites More sharing options...
KrisMunro Posted August 20, 2008 Share Posted August 20, 2008 Sorry for not clarifying that. Sometimes it's hard to know what to include and what not to. Sorry for the late response as well.. I've been away on holiday, so I hope you haven't been in a hurry to get this done. My database is set up quite simply. Rather than have a script that resizes your images on the fly, I have a thumbnail image and a proper image. My use of these in my code (in hindsight) would have been quite confusing. The $thumb and $location is where the images are located. The $thumb is the filename of the thumnail, and the $location is the filename of the full-sized image: 'thumb0034.jpg' and 'image0034.jpg'. These are examples only.. if you wanted some additional security, you'd be best off generating random names for you filenames, otherwise people could determine the location of you full-sized image by knowing the thumbnail suffix (the number). If you wanted a script that generates random names, let me know and I'll post it. The $imageID is the Key. When you want to display the images, you use this: print "<img src=\"pics/thumb/".$file."\" width=321 height=241 alt=\"Thumbnail Image\">"; Or use the link script I posted below. As an alternative, you can create a form that will Post rather than Get information between pages; use your thumbnail as a button for a form. To the end-user, they wont know the difference, but it gives you some benefits in how you handle links. This helps with keeping your file names secret, keeps addresses small, and also allows you to pass over a much larger amount of information discretely, which means you have greater flexibility in site maneuverability... but it's a little harder to do. Quote Link to comment https://forums.phpfreaks.com/topic/116944-gallery/#findComment-620712 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.