0

Hi i want the values which are selected should be stored in a session. here i have stored all the values which are available how to do it.......pls give me solution.............

<?php

	include('database.php');


 $stype=$_POST['category'];
if($stype=="service_category")
   { 
	 
	 $result = mysql_query("SELECT * FROM  service_category ");
	while($row = mysql_fetch_array($result))
		{
		?><input type="Checkbox" name="a[]" id="a[]"  value="servicec"><?echo $row['servicec'];
		echo "<br />";
		$a[$i]=$row['servicec'];
		$i++;
		$_SESSION['a1']=$a[i];
			//	echo  $_SESSION['a1'];

		}
		$_SESSION['a1']=$a; 
		

   }
2
Contributors
1
Reply
2
Views
8 Years
Discussion Span
Last Post by vicky_rawat
0

Hi,

for this you do not need to store all the values in session.

while($row = mysql_fetch_array($result))
{
?><input type="Checkbox" name="a[]" id="a[]" value="<?=$row['servicec']?>"><?echo $row['servicec'];
echo "<br />";
$i++;
}

now when you will post this page then in next page you will get only those values that are selected then you can store those values in session.

You can test the following example.

<?
   if(isset($_POST["submit"]))
	{
		$aa = $_POST["a"];
		foreach($aa as $i)
		{
			echo $i." ";
		}		
		exit;
	}

?>

<form method=post action="">
<input type=checkbox name=a[] id=a[] value=1> 
<input type=checkbox name=a[] id=a[] value=2> 
<input type=checkbox name=a[] id=a[] value=3> 
<input type=checkbox name=a[] id=a[] value=4> 
<input type=checkbox name=a[] id=a[] value=5> 

<input type=submit name=submit value=submit>
</form>
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.