Hi i have kept the array of values in a session so how to retrieve those values from the session in the next page .........can anybody help me

$result = mysql_query("SELECT * FROM  services ");
			while($row = mysql_fetch_array($result))
			{
				?><input type="Checkbox" id="c[]"  value="servicess"> <?echo $row['servicess'];
				echo "<br />";
				$c[i]=$row['servicess'];
				$i++;
				 $_SESSION['c1']=$c[i];
			}

Eg. test1.php

<?php
session_start();
$array = array();
for($i=0;$i<5;$i++) {
$array[] = $i; //insert $i to an array
}
$_SESSION['array'] = $array; //assign $array to the session variable $_SESSION['array']
?>

test2.php

<?php
session_start();
$array = $_SESSION['array']; //assign $_SESSION['array'] to $array
foreach($array as $value) {
print $value; //print $array contents
}

P.S. Dude, don't you understand english ? How hard is it to use code-tags ?

Edited 3 Years Ago by mike_2000_17: Fixed formatting

Comments
Hell ya dude!

Hi iam getting this error.........i wrote like this in second page.....in first page i wrote as i mentioned before........

$a = $_SESSION['a1']; //assign $_SESSION['array'] to $array
foreach($a1 as $value) {
echo $value; //print $array contents

Warning: Invalid argument supplied for foreach() in D:\xampp\htdocs\demo10-07-08\contractor.php on line 29

I think nothing is in $_SESSION.
After session_start, print what's in session. print_r($_SESSION);

Hi iam getting this error.........i wrote like this in second page.....in first page i wrote as i mentioned before........
$a = $_SESSION; //assign $_SESSION to $array
foreach($a1 as $value) {
echo $value; //print $array contents

Warning: Invalid argument supplied for foreach() in D:\xampp\htdocs\demo10-07-08\contractor.php on line 29

Your string key appears to be "a", not "a1"...try changing it to a1 maybe?

Comments
Ah damn.. How did I miss that ;)
This article has been dead for over six months. Start a new discussion instead.