Jump to content

Gallery Script


ThermalSloth

Recommended Posts

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

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

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

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. :D (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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.