0

Hi here the the values which are from the table will be stored in an session....before that which is displayed with an checkbox.......but what i want to do here is i want those values which are clicked should be stored in a session and i want to display them in the next page........... help me

<?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" id="a[]"  value="servicec"><?echo $row['servicec'];
		echo "<br />";
		$a[i]=$row['servicec'];
		$i++;
		$_SESSION['a1']=$a[i];
			//	echo  $_SESSION['a1'];

		}
   }
2
Contributors
3
Replies
4
Views
8 Years
Discussion Span
Last Post by vicky_rawat
0

Hi,

Two things I want to tell you.
1. the code that you have written will store the last value in session variable a1.

so your code should be something like this.

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

2. As per your requirement, the clicking event is client side event, so you can not directly modify the array stored in session.
for that you will either need to use AJAX or you will need to post this page and then in next page you can catch the checkboxes values which were clicked on previous page.

-1

I tried with ur code..........it will display only the last value................

<?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;
		$a = $_SESSION['a1']; //assign $_SESSION['array'] to $array
			foreach($a as $i) 
				{
				echo $i;
				}
   }
Votes + Comments
You are still not using the [code] tags. Bad bad..
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.