kls1974 Posted January 12, 2007 Share Posted January 12, 2007 Hi.I-m trying to make a simple image gallery and I don't want to use javascripts or frames (iframes) so PHP is the way to go (I think), so I spend the last 3 days trying to learn PHP programming and have a few problems?I need a gallery with thumbs in a vertical row with a scrollbar and a full size image in the center of the page (fixed)I made a simple script where I use <a href="gal.php?pic=...> on the thumbs and then use <img src=" $_GET['pic'] "> to show the file and it works great but the screen refreshes and scrolls to the top of the screen/scrollbar!This is bad because you have to scroll down to click the next thumb every time?Is there any way other than GET to make this kind of gallery or a way not to refresh the screen on link click?Here's the PHP file (gal.php):[code]<?php$thumbs = "tmb/";$pics = "pic/";if ($handle = opendir($thumbs)) { while (false !== ($file = readdir($handle))) { if ($file != "." && $file != "..") { $files[] = $file; } } closedir($handle); } sort ($files);foreach($files as $file) { echo '<a href="gal.php?pic=' . $file . '"><img src="' . $thumbs . $file . '" /></a><br>'; }if ($_GET['pic'] == NULL) { echo "no picture chosen <p>" ;}else {echo '<p><img src="' . $pics . $_GET['pic'] . '" style="position: fixed; left: 50%; top: 50%; margin-left: -320px; margin-top: -240px"><p>';}?>[/code] Link to comment https://forums.phpfreaks.com/topic/33857-can-i-do-a-_get-without-refreshing-the-screen/ Share on other sites More sharing options...
jwk811 Posted January 12, 2007 Share Posted January 12, 2007 im not too sure how you could do that but what you could do is have it like that and set the pic in <p> tags with an id that you can add to the href so it will auto scroll to that image.. like <p id="image"><a href="gal.php?pic=...#image> <img src=""></p> Link to comment https://forums.phpfreaks.com/topic/33857-can-i-do-a-_get-without-refreshing-the-screen/#findComment-158892 Share on other sites More sharing options...
scotmcc Posted January 12, 2007 Share Posted January 12, 2007 You could probably use a named anchor to position the browser...<a name="PutBrowserHere"><img></a><a href="link_to_page.html#PutBrowserHere">Link</a>You will probably have to check my syntax :)Scot Link to comment https://forums.phpfreaks.com/topic/33857-can-i-do-a-_get-without-refreshing-the-screen/#findComment-158895 Share on other sites More sharing options...
kls1974 Posted January 12, 2007 Author Share Posted January 12, 2007 Thanks, it works :)I changed the foreach() section to:foreach($files as $file) { [b]$tmptag = strlen($file)-4;$tag = substr($file, 0, $tmptag);[/b]echo '<a name="' . $tag . '" href="gal.php?pic=' . $file . '#' . $tag . '"><img src="' . $thumbs . $file . '" /></a><br>'; }But it would be nicer if I could use some other POST method so the screen wouldn't have to be reloaded as with the <a href....> command?Is there any other way that I can do this? (assing a value to [i]$pic[/i] by clicking on a image thumbnail and use this value to change the displayed image (<img src="path/' . [i]$pic[/i] . ' "/>) and updating just the image without refreshing the screen?) Link to comment https://forums.phpfreaks.com/topic/33857-can-i-do-a-_get-without-refreshing-the-screen/#findComment-158911 Share on other sites More sharing options...
dpabla Posted January 14, 2007 Share Posted January 14, 2007 that would be using AJAX and PHP - ajax allows the page to not refresh....hope that points you on the right direction Link to comment https://forums.phpfreaks.com/topic/33857-can-i-do-a-_get-without-refreshing-the-screen/#findComment-160151 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.