Passing Multiple Parameters to an img src

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
LucyC
Forum Newbie
Posts: 4
Joined: Mon Jul 14, 2008 7:29 am

Passing Multiple Parameters to an img src

Post by LucyC »

Hi,

I wish to pass multiple parameters to an img src. I already have successfully passed the one parameter using the following code:

<img src="Chart.php?graphdata1=<?php echo $datacolumns1 ?>">

can anyone tell me what the syntax would be to pass a second parameter? eg if I wished to pass $datacolumns2 as graphdata2, maybe something like (although this doesn't work)....

<img src="Chart.php?graphdata1=<?php echo $datacolumns1 graphdata2=<?php echo $datacolumns2 ?>">

Many thanks
Dynamis
Forum Contributor
Posts: 122
Joined: Thu Jul 10, 2008 3:15 pm
Location: Indiana, US

Re: Passing Multiple Parameters to an img src

Post by Dynamis »

You were very close. If you are using the GET method, which I assume you are by your code, you need "&" between all of your variables. The following code should work correctly.

Code: Select all

<img src="Chart.php?graphdata1=<?php echo $datacolumns1; ?>&graphdata2=<?php echo $datacolumns2; ?>">
LucyC
Forum Newbie
Posts: 4
Joined: Mon Jul 14, 2008 7:29 am

Re: Passing Multiple Parameters to an img src

Post by LucyC »

Many thanks for this - it works!
Post Reply