nice.guy.nige said:
Thanks for the solution, Nigel. The reason I asked for a javascript
is that after initially asking for a php solution (in alt.php), all I
received was, "you should use a client-side solution such as
javascript or dhtml." I hate to trouble you into contriving a whole
new solution if the one you've provided works fine, but if you don't
mind I'd at least like to know what some of the differences are
between using, for this particular problem, client-side and server-
side code so that I can improve my decisions in choosing the right
type of solution before requesting one. Thanks again, Nigel.
Hi Steve,
One big advantage of server-side over client-side is that you don't have to
rely on the products used by the end-user. The server-side script produces
the html code and the server serves it to the end user. Shazam! The
javascript version relies on javascript being available to - and enabled
by - the end user. Also, different browsers handle the javascript in
different ways, wheras here it is sending nothing but html to the end user,
which will be interpreted in pretty much the same way by most browsers.
Have a go at this. Save it as imgDisplay.php and set the path to point to
where the images are stored.
<html>
<head>
<title>Imgage Display using PHP</title>
</head>
<body>
<h1>Image Display using PHP</h1>
<?PHP
if(!isset($pn)) {
$pn = "pict1.jpg";
$alt = "picture one";
}
$path="./";
$picname = $path.$pn;
$pic_size = getimagesize("$picname");
print("<p>");
print("<img src=\"$picname\" $pic_size[3] alt=\"$alt\">");
print("</p>");
?>
<p>[
<a href="imgDisplay.php?pn=pict1.jpg&alt=picture%20one">1</a> |
<a href="imgDisplay.php?pn=pict2.jpg&alt=picture%20two">2</a> |
<a href="imgDisplay.php?pn=pict3.jpg&alt=picture%20three">3</a> |
<a href="imgDisplay.php?pn=pict4.jpg&alt=picture%20four">4</a> |
<a href="imgDisplay.php?pn=pict5.jpg&alt=picture%20five">5</a>
]</p>
</body>
</html>
... This could be expanded to hold all the alt texts in an array (so you
could have more complicated alt text without ending up with an
incomprehensible URL!) for example.
Hope that helps,
Nige
--
Nigel Moss.
Email address is not valid. (e-mail address removed). Take the dog out!
http://www.nigenet.org.uk | Boycott E$$O!!
http://www.stopesso.com
"How strange the change from major to minor..."
Wow, thanks Nigel! This is great information...I'm learning more and more
about how this stuff works. It really makes it so much easier to learn when
the code is so tidy like you've made it. I've been using
www.php.net to
learn more about the code you gave me and I swear I've almost got it
working. I've adapted your solution to fit the proper titles, filenames,
file extensions, etc. As you will see, there are 25 gifs I'm trying to have
available for display. The error message that I keep getting is this:
"Parse error: parse error, unexpected T_STRING in
d:\websites\stevedurkinnet\wwwroot\TMPbjeclick0n.php on line 27"
Line 27 is the first of the 25 lines that look like this: <a href="problem
lies somewhere in here"></a>.
I'm developing a decent understanding of some of the variables you've
defined and how they interact, but I don't understand the purpose of the
$alt variable or the & thing that separates the href="XXXXXX" from the
alt="XXXXXX" You've been such great help so far that I feel guilty asking
anything else of you, but I feel that I am so very close to having the final
solution. And for what it's worth to you, you'll be the first person to see
my digital paintings.
Thanks for everything, Nigel,
Steve
Here is the code:
<html>
<head>
<title>Paintings</title>
<link href="Style Sheets/Style01.css" rel="stylesheet" type="text/css">
</head>
<body>
<div align="center">
<?PHP
if(!isset($pn)) {
$pn = "Animals.gif";
$alt = "picture one";
}
$path = "Images\Paintings\";
$picname = $path.$pn;
$pic_size = getimagesize($picname);
print(<p>);
print(<img src=\"$picname\" $pic_size[3] alt=\"$alt\">);
print(</p>);
?>
<p>
<a href="Paintings.php?pn=Animals.gif&alt=picture%20one">Animals</a> |
<a
href="Paintings.php?pn=Antimatter.gif&alt=picture%20two">Antimatter</a>
|
<a href="Paintings.php?pn=Battle.gif&alt=picture%20three">Battle</a> |
<a href="Paintings.php?pn=Bear.gif&alt=picture%20four">Bear</a> |
<a href="Paintings.php?pn=Bird.gif&alt=picture%20five">Bird</a> |
<a href="Paintings.php?pn=Cabin.gif&alt=picture%20six">Cabin</a> |
<a href="Paintings.php?pn=Castle.gif&alt=picture%20seven">Castle</a> |
<a href="Paintings.php?pn=City.gif&alt=picture%20eight">City</a> |
<a href="Paintings.php?pn=Colorado.gif&alt=picture%20nine">Colorado</a>
|
<a
href="Paintings.php?pn=Droidling%20and%20Mother.gif&alt=picture%20ten">D
roidling and Mother</a> |
<a href="Paintings.php?pn=Dude.gif&alt=picture%20eleven">Dude</a> |
<a
href="Paintings.php?pn=Eating%20Demon.gif&alt=picture%20twelve">Eating
Demon</a> |
<a href="Paintings.php?pn=Faces.gif&alt=picture%20thirteen">Faces</a> |
<a href="Paintings.php?pn=House.gif&alt=picture%20fourteen">House</a> |
<a href="Paintings.php?pn=Path.gif&alt=picture%20fifteen">Path</a> |
<a href="Paintings.php?pn=Phantom.gif&alt=picture%20sixteen">Phantom</a>
|
<a href="Paintings.php?pn=Plan.gif&alt=picture%20seventeen">Plan</a> |
<a href="Paintings.php?pn=Skull.gif&alt=picture%20eighteen">Skull</a> |
<a
href="Paintings.php?pn=Snowman.gif&alt=picture%20nineteen">Snowman</a> |
<a href="Paintings.php?pn=Star.gif&alt=picture%20twenty">Star</a> |
<a href="Paintings.php?pn=Tree.gif&alt=picture%20twentyone">Tree</a> |
<a href="Paintings.php?pn=Vortex.gif&alt=picture%20twentytwo">Vortex</a>
|
<a href="Paintings.php?pn=Warp.gif&alt=picture%20twentythree">Warp</a> |
<a
href="Paintings.php?pn=Wizard.gif&alt=picture%20twentyfour">Wizard</a> |
<a href="Paintings.php?pn=Wolf.gif&alt=picture%20twentyfive">Wolf</a>
</p>
</div>
</body>
</html>