Page 1 of 1
Using a sending information through a link
Posted: Sat Mar 01, 2003 2:54 pm
by nigma
Is there a way I can do something like
<a href="viewScreenshot.php" name="screenshot" value="sc1.bmp">
then when you click it viewScreenshot.php gets the value of the link
( screenshot ) and then opens up the picture sc1.bmp ( because that is value of screenshot )??
Thanks for all help provided.
Posted: Sat Mar 01, 2003 3:50 pm
by patrikG
href can't have a value assigned. Try "<a href='viewscreenshot.php?id=screenshot1'>ScreenshotName</a>".
Posted: Sat Mar 01, 2003 8:08 pm
by nigma
If I did that how would I call its ID in viewScreenshot.php?
Posted: Sat Mar 01, 2003 8:56 pm
by volka
appending key/value-pairs to the url is called
GET-method (same as setting method="GET" for a form).
In recent versions of php they are stored in
the superglobal array $_GET
Posted: Sat Mar 01, 2003 9:01 pm
by nigma
So it would be $_GET['id']??
Posted: Sat Mar 01, 2003 9:49 pm
by nigma
How would I store what was after the ?id=whatiwanttostore in a variable?
Posted: Sun Mar 02, 2003 8:52 am
by CONFIQ
id=value&variable=value
Than $_GET['id] is value and $_GET['variable] is value
Posted: Sun Mar 02, 2003 11:56 am
by nigma
Here is the link: <a href="viewScreenshot.php?id=sc1.bmp">
Here is viewScreenshot.php:
<html>
<head>
<link rel="stylesheet" type="text/css" href="style.css" />
</head>
<body>
<div align="center">
<?php
$picToView = $_GET['id];
echo("<image src=\"$picToView\">");
?>
</div>
</body>
</html>
Why doesn't this work?
Posted: Sun Mar 02, 2003 2:27 pm
by patrikG
should be
Make sure the image is in the same directory as the script. Otherwise you'll have to specify where the image-folder is (e.g. "../screenshots/").