Page 1 of 1

How to send a variable with 2 values in a link?

Posted: Mon Mar 21, 2011 12:49 am
by mine
Hi All,
Im having trouble to send a variable with 2 values in a link
deptid = COM_CFO and COM_FIN

<area shape="rect" coords="595,381,701,419" href="" onMouseOver="open_new_window('dept_stafflist.php?deptid=COM_CFO','','width=500,height=300,left=10,top=10,scrollbars=1,location=no,status=no')" onMouseOut="close_window()" alt="cfo" />

how do i put it?
dept_stafflist.php?deptid=COM_CFO&&COM_FIN wont work.
dept_stafflist.php?deptid=COM_CFO&&deptid=COM_FIN wont work too.

Please help.
Thanks in advance.

Re: How to send a variable with 2 values in a link?

Posted: Mon Mar 21, 2011 1:06 am
by adityamenon90
send them in an array

Code: Select all

dept_stafflist.php?deptid[]=COM_CFO&deptid[]=COM_FIN

Re: How to send a variable with 2 values in a link?

Posted: Mon Mar 21, 2011 1:53 am
by mine
thanks but is there any other way else?
im not good in array.

Re: How to send a variable with 2 values in a link?

Posted: Mon Mar 21, 2011 10:48 pm
by adityamenon90
You must get good. Arrays are incredibly useful - actually indispensable and irreplaceable. You just gotta power through the pain of wrapping your head around using them for the first time.

Re: How to send a variable with 2 values in a link?

Posted: Tue Mar 22, 2011 1:17 pm
by social_experiment
How do want to use these values? I am guessing on page dept_stafflist.php you will retrieve them using $_GET? If so, the other poster has a good point. Using the array is an easy method, and if you look at the result, it is not difficult to extract the values

Code: Select all

<?php
 // assuming your url is dept_stafflist.php?deptid[]=COM_CFO&deptid[]=COM_FIN
 // retrieve the values in the following manner

 $_GET['deptid'][0]; // contains COM_CFO
 $_GET['deptid'][1]; // contains COM_FIN
?>