jwlarson3rd has asked for the wisdom of the Perl Monks concerning the following question:

#!/usr/bin/perl use CGI; use strict; use DBI(); my $q=new CGI(); my $dbh = DBI->connect("DBI:mysql:bthcraft", "#######", "#########"); print " Can't connect to database\n" if ! defined $dbh; my $nme=$q->param('name'); my $stht = $dbh->prepare("SELECT * FROM images where username = '$n +me'"); $stht->execute(); print $q->header(); print $q->start_html('display'); while (my @dat=$stht->fetchrow_array()) { print "<INPUT TYPE=IMAGE NAME=image height='100' width='100' SRC='http://typhoon.he.net/~bthcraft/$dat[0]/images/$dat[1]' >"; } print $q->end_html; $stht->finish; $dbh->disconnect;
the above script retrieves info from a mysql database and uses the info to display images on a page. I need to add some funcitonality that when a images are clicked on a larger images is displayed in a clickable slide show format

any help would be appreciated
JOHN LARSON

Code tags - dvergin 2003-12-03

Replies are listed 'Best First'.
Re: clickable slide show perl
by pg (Canon) on Dec 03, 2003 at 21:19 UTC

    Take a look at Tk::Thumbnail, which can easily be used to render your list of pictures.

    The thumbnails are by default clickable.

    use Tk; use Tk::Thumbnail; use strict; my @thumbnails = ("ant_logo_small.gif", "current.gif", "group-logo.gif +"); my $mw = MainWindow->new; $mw->geometry("600x400"); my $thumb = $mw->Thumbnail(-images => \@thumbnails, -labels =>0, -widt +h => '50', -height => '50', -command =>\&openwin)->pack; MainLoop; sub openwin { my $tw = MainWindow->new; my $pic = $tw->Photo(-file=>$_[1]); $tw->Label(-image => $pic)->pack; };
      thanks for input unfortunately that module TK::Thumbnail doesn't exists on the server. I can already populate a generated page with image buttons using the info from the database. what I need to do is when the the onclick event is generated a slide show with next prev and exit button is generated. I was thinking sub routine jwlarson3rd
Re: clickable slide show perl
by Joost (Canon) on Dec 03, 2003 at 21:24 UTC
    Hello and welcome,

    Please check your formatting next time (that's what the preview button is for).

    I don't know exactly what your question is, but here are some quick pointers:

    Image resizing: you can use Image::Magick to scale images. Alternatively you can just resize an image in HTML using the width and height attributes of the IMG tag (ugly and slow, but it works).

    As for the slide show: I'd just use something like:

    print qq[<a href="show.cgi?image=$previd">previous</a> <a href="show. +cgi?image=$nextid">next</a>];
    And get the $previd and $nextid form your database.

    Joost

      sorry about formatting. exactly how would I get $previd and $ nextid from mysql database.I already scale the pictures and compress on upload.I can already display all of the images as buttons on one generated page (cgi.pm) what I am trying to do is when a user clicks on a thumbnail image he activates (using onclick event ) clickable slide show with next,prev,exit links.
Re: clickable slide show perl
by Roy Johnson (Monsignor) on Dec 03, 2003 at 21:40 UTC
    <code> tags! <code> tags!

    The PerlMonk tr/// Advocate