gallery help

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
regularguy
Forum Newbie
Posts: 6
Joined: Sat Nov 28, 2009 11:13 pm

gallery help

Post by regularguy »

Hi,
somebody send me this script (below) to make gallery for my site, it works well!
I just wondering, if some one can help me on how to make clicked thumbs open (the big picture) on the new windows?
.... click the big picture back to the thumbs? or new template windows?
THANKS. and happy holidays !!!!!!!!

<?php
error_reporting(E_ALL);
if(!is_dir('thumbs')) die('thumbs directory was not found');
$file_list = array();

if ($handle = opendir('thumbs')) {
while (false !== ($file = readdir($handle))) {
if (strtolower(array_pop(explode('.',$file))) == 'jpg') {
$file_list[] = $file;
}
}
closedir($handle);
}

$count = 0;
$total = count($file_list);
?>

<?php

sort($file_list);
foreach($file_list as $file) {
$path = 'thumbs/'.$file;
if(!is_file($file)) continue;
echo "<a href=\"{$file} \"><img src=\"{$path}\" class=\"pic\" alt=\"{$file}\"></a>
";
}

?>
User avatar
AbraCadaver
DevNet Master
Posts: 2572
Joined: Mon Feb 24, 2003 10:12 am
Location: The Republic of Texas
Contact:

Re: gallery help

Post by AbraCadaver »

target="_blank" to open in a new window. I don't know about the other because you will already have the thumbs open in the first window.

Code: Select all

echo "<a href=\"{$file}\" target=\"_blank\"><img src=\"{$path}\" class=\"pic\" alt=\"{$file}\"></a>
 
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
regularguy
Forum Newbie
Posts: 6
Joined: Sat Nov 28, 2009 11:13 pm

Re: gallery help

Post by regularguy »

That's give me some ideas!
THANKS !
User avatar
daedalus__
DevNet Resident
Posts: 1925
Joined: Thu Feb 09, 2006 4:52 pm

Re: gallery help

Post by daedalus__ »

OHHHHHHHH

hey. use javascript to open a div with the selected image in it. that way you can style it make it pretty and apply scripts to it. opening a new window is so ugly :(
User avatar
AbraCadaver
DevNet Master
Posts: 2572
Joined: Mon Feb 24, 2003 10:12 am
Location: The Republic of Texas
Contact:

Re: gallery help

Post by AbraCadaver »

daedalus__ wrote:OHHHHHHHH

hey. use javascript to open a div with the selected image in it. that way you can style it make it pretty and apply scripts to it. opening a new window is so ugly :(
Good point daedalus__! Just answering the question.
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
User avatar
daedalus__
DevNet Resident
Posts: 1925
Joined: Thu Feb 09, 2006 4:52 pm

Re: gallery help

Post by daedalus__ »

well that might be a little above his skill level but a good idea for the future
User avatar
AbraCadaver
DevNet Master
Posts: 2572
Joined: Mon Feb 24, 2003 10:12 am
Location: The Republic of Texas
Contact:

Re: gallery help

Post by AbraCadaver »

Myself, I would probably link to a PHP file that outputs the img tag with whatever HTML I wanted though. And use the class for style:

Code: Select all

echo '<a href="show_image.php?image='.$file.'" target="_blank"><img src="'.$path.'" class="pic" alt="'.$file.'"></a>'; 
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
regularguy
Forum Newbie
Posts: 6
Joined: Sat Nov 28, 2009 11:13 pm

Re: gallery help

Post by regularguy »

Hey,
You right that is above my level.
I just learning here, what can I say I'm 56 year old just start to learn php... just the regular guy.
I can't even figure it out to sort the photo so the new one will be on top... almost discouraging this php is.

Thanks for helps, this is a good forum and good people.
User avatar
AbraCadaver
DevNet Master
Posts: 2572
Joined: Mon Feb 24, 2003 10:12 am
Location: The Republic of Texas
Contact:

Re: gallery help

Post by AbraCadaver »

regularguy wrote:Hey,
You right that is above my level.
I just learning here, what can I say I'm 56 year old just start to learn php... just the regular guy.
I can't even figure it out to sort the photo so the new one will be on top... almost discouraging this php is.

Thanks for helps, this is a good forum and good people.
Don't ever get discouraged. Work at it and come here if you need help.
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
Post Reply