View Full Version : parsing parameters passed from htm

04-13-2007, 09:06 PM
I think this should be easy but don't know how to do it.

I want to pass in three parameters from a href to a php script like so
<a href="showimage.php?image=image1.jpg?width=100?height=100">

The php script should get the image and display it using the height and width parameters.

I'm not sure if the href line is structured correctly and haven't a clue how to parse it in PHP

04-13-2007, 09:11 PM
First off, the link should be like so:

<a href="showimage.php?image=image1.jpg&amp;width=100&amp;height=100">

Then, to get the variables in your php code, you must request them by using $_GET, $_POST, or $_REQUEST like so:


/*assign the variables*/
$image = $_GET['image'];
$width = $_GET['width'];
$height = $_GET['height'];

//rest of code here

Hope this helps.

04-13-2007, 09:26 PM
<a href="showimage.php?image=image1.jpg&amp;width=100&amp;height=100">& is a special character in HTML, so it has to be escaped. You can also use a semicolon (;).

04-13-2007, 09:28 PM
I thought that I added that, but must have erased it when putting the color to it. Anyways, thanks for pointing that out.

04-13-2007, 10:03 PM
That's great, folks. Many thanks