PDA

View Full Version : how to pass array in querystring


esthera
04-16-2007, 08:27 AM
i have a array taken form checkboxes so
schools is an array taken from checkbox

now if this was not multiple to pass it in the querystring i would do
$schools=$_REQUEST['schools'];
and in the querystring
&schools=$schools

how can i pass the whole array in the querystring? Is this possible?

CFMaBiSmAd
04-16-2007, 02:26 PM
Use the implode() function with a separator character of your choice that does not appear in the values, such as "|" - http://php.net/implode

esthera
04-16-2007, 02:39 PM
you mean to make it a string with a separator? but then how can i make it posted the same as it comes from the select box?

CFMaBiSmAd
04-16-2007, 02:49 PM
Perhaps if you gave an example of what you are trying to do?

I thought you wanted to pass an array as part of a query string?

esthera
04-16-2007, 03:00 PM
I want to pass it as part of the query string as then I read it as follows


$sql=$sql. " where (";
foreach ($_REQUEST['schools'] as $value) {
if($i>0){
$sql=$sql." OR ";
}
$sql=$sql. "S.id=" . $value;

$i=$i+1;
}

now i want it to be request['schols'] wether it came from the checkboxes or the querystring - is this possible