ThermalSloth Posted April 5, 2010 Share Posted April 5, 2010 Hi, I'm trying to create a gallery script in PHP. Thing is, I'm not very skilled in it and I wouldn't know how I would do this. I was thinking about a simple slideshow like on www.nerfnow.com (hover over the cartoon with your mouse to see the arrows). So this would just grab the first file, display it, and if there are more files you can just go to the next or previous. (Only needs to get the content of 1 folder) I was wondering if anybody could please help me with this? Regards. Link to comment https://forums.phpfreaks.com/topic/197690-gallery-script/ Share on other sites More sharing options...
trq Posted April 5, 2010 Share Posted April 5, 2010 I was wondering if anybody could please help me with this? Sure, what is the problem? Link to comment https://forums.phpfreaks.com/topic/197690-gallery-script/#findComment-1037463 Share on other sites More sharing options...
ThermalSloth Posted April 5, 2010 Author Share Posted April 5, 2010 I was wondering if anybody could please help me with this? Sure, what is the problem? The problem would be that I have absolutely no idea where I would start with this, and how I would go through the process Link to comment https://forums.phpfreaks.com/topic/197690-gallery-script/#findComment-1037465 Share on other sites More sharing options...
TeddyKiller Posted April 5, 2010 Share Posted April 5, 2010 What you'd do.. is pagination. If your images are placed in a database too, you grab these images via an SQL query in the pagination. Limitting it to 1 per page, or whatever was desired. This wouldn't be a very good slideshow though, slideshows are usually smooth and do not include refreshing page.. (As refreshing the page to get to the next image is really annoying) So what you'd do for this, is probably a Javascript/AJAX slideshow gallery Link to comment https://forums.phpfreaks.com/topic/197690-gallery-script/#findComment-1037466 Share on other sites More sharing options...
ThermalSloth Posted April 5, 2010 Author Share Posted April 5, 2010 What you'd do.. is pagination. If your images are placed in a database too, you grab these images via an SQL query in the pagination. Limitting it to 1 per page, or whatever was desired. This wouldn't be a very good slideshow though, slideshows are usually smooth and do not include refreshing page.. (As refreshing the page to get to the next image is really annoying) So what you'd do for this, is probably a Javascript/AJAX slideshow gallery I see, the thing is that my images are not placed in a database, else I'd know how to make a list out of it, and then use javascript to make a gallery out of it. (because of this page.) And it doesn't have to be a real slideshow, just something so the user doesn't have to go back to the index and select the next image. (Thanks for the quick replies ) Also, TeddyKiller, you have a typo in your sig :x It's "You're dead" instead of "Your dead".. Sorry :x Link to comment https://forums.phpfreaks.com/topic/197690-gallery-script/#findComment-1037471 Share on other sites More sharing options...
TeddyKiller Posted April 6, 2010 Share Posted April 6, 2010 It's not really a typo, it was my failed attempt of bad grammar at the time I wrote it. Have you thought about inserting them into the database? The script you gave, is very nice. I might actually use it. I'm not sure of how to do it in a pagination method. Though I did a little search on a massive search engine that you might call google, and came up with this. (Some sarcasm) The demo is here http://bonrouge.com/cheerspics.php - You can hover over the images, and it displays a big one, or you can click on an image, and it stays there until the next click. You may change some bits, not quite sure. Haven't tested it, though it is obvious you will need to change $dir="thumbs72/"; so that it matches your directory. <?php $dir="thumbs72/"; $path=getcwd().'/'.$dir; $handle=opendir($path); ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head> <title>CHEERS pics</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <style type="text/css"> <!-- body { background-color:#fff; } ul, li { padding:0; list-style:none; } ul { position:relative; width:745px; margin:auto; background:url(cheerslogo500.jpg) 125px 70px no-repeat; border:1px solid #ccc; height:525px; padding-left:5px; } li { margin:5px 0; float:left; width:82px; height:54px; background-position:center center; background-repeat:no-repeat; } <?php $i=1; while ($file=readdir($handle)) { if (strpos($file, '.jpg')) { echo "#pic$i {".(($i>9)? ' margin-top:400px;' :'')." background-image:url($dir$file); } "; $i++; } } ?> a { display:block; height:54px; } a img { position:absolute; top:70px; left:125px; width:1px; border:0; } * html a:hover { display:block; height:53px; } a:hover img { width:500px; } a:active img, a:focus img { z-index:1; width:500px; } --> </style> </head> <body> <ul> <?php $i=1; $handle=opendir($path); while ($file=readdir($handle)) { if (strpos($file, '.jpg')) { echo "<li id=\"pic$i\"><a href=\"#n\"><img src=\"/thumbs500/$file\" alt=\"pic$i\" /></a></li> "; $i++; } } ?> </ul> </body> </html> Link to comment https://forums.phpfreaks.com/topic/197690-gallery-script/#findComment-1037494 Share on other sites More sharing options...
ThermalSloth Posted April 6, 2010 Author Share Posted April 6, 2010 Thanks for the reply, I've tried the code but it's not really working because of the large amount of images I have in the folders. (150-300 easily..) I'm also busy with someone else in an IRC channel, he might know something, he said Link to comment https://forums.phpfreaks.com/topic/197690-gallery-script/#findComment-1037503 Share on other sites More sharing options...
TeddyKiller Posted April 6, 2010 Share Posted April 6, 2010 Ah.. If it's only displaying 9 images, then this is your key echo "#pic$i {".(($i>9)? ' You'd change 9 to something else. But the person IRC may be better help to you anyway I'm still learning. Link to comment https://forums.phpfreaks.com/topic/197690-gallery-script/#findComment-1037514 Share on other sites More sharing options...
ThermalSloth Posted April 6, 2010 Author Share Posted April 6, 2010 Yeah we're pretty far with the script now, will post here when it's finished Link to comment https://forums.phpfreaks.com/topic/197690-gallery-script/#findComment-1037684 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.