Forum Moderators: coopster & phranque

Message Too Old, No Replies

open dynamic page with an image and caption/link

new page created for each link

         

saucemaster

1:37 am on May 12, 2004 (gmt 0)



i would like to have a link in an html file that when clicked opens a new page that has an image and some information about that image.

here is an example of what i would like to do; i hope it is clear:

let's say i have a file 'cat.jpg'; when you click the link, a new page opens up with the image and a caption 'this is a cat'. the same script would also open up 'dog.jpg' with the caption 'this is a dog'. i have many images that i would like to display, but i don't want to build a page for each one. i found a script that opens up all the images in a formatted page, but i don't know how to add the captions. is this a job for perl? thanks in advance.

volatilegx

1:33 pm on May 12, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Sure, perl can handle this, but you'd need some type of database to hold the text you want to display, and associate that text with the various graphics files. A MySQL database would be fast and easy to work with. Actually, though, I prefer to use PHP when working with a MySQL database.

Welcome to WebmasterWorld :)

markanthony

6:07 pm on May 14, 2004 (gmt 0)

10+ Year Member



There are some other options that you can use to accomplish this without utilizing a database.

You can generate the html pages with a relatively simple perl script.

do something like:

ls > imageList.txt

then in a perl script.

while(<>)
{
chomp;
&writeTemplate($_);
}

In your writeTemplate sub you will need to write out to a file probably using the image name. Then 'here' document quoting to make it easy to create the file.

example:

print FILE <<EOF;
<html>
<head>
</head>
<body>
<img src="$_">
<p> $caption </p>
</body>
</html>
EOF

You will need to pull in and connect the caption to the image name somehow but that shouldn't be too difficult.

jatar_k

9:06 pm on May 14, 2004 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Welcome to WebmasterWorld markanthony

markanthony

3:01 pm on May 17, 2004 (gmt 0)

10+ Year Member



Thanks for the welcome, I am happy to have discovered this new resource.