Hi is this correct?
actually i have declared a,b,c as an array and i want store it in a session and display them i am not even getting error, it is showing blank page......pls help me
is the declaration of an array is correct ?

<? 
 session_start();
				$a=$_POST['a'];
				$b=$_POST['b'];
				$c=$_POST['c'];
				$otherservices=$_POST['otherservices'];
				session_register('a');
				session_register('b');
				session_register('c');	
				session_register('otherservices');	
		
   echo $_SESSION['emailid'];    
 include("header.php") ?>
<html>
<body>
</body>
</html>
<?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 />";
	}

   }
  
  else if($stype=="servicetype")
		 { 
	 
		$result = mysql_query("SELECT * FROM  service_type ");
		while($row = mysql_fetch_array($result))
				{
				?><input type="Checkbox" id="b[]"  value="servicet"> <?echo $row['servicet'];
				echo "<br />";
				
				}
			}
else if($stype=="services")
		{	
			$result = mysql_query("SELECT * FROM  services ");
			while($row = mysql_fetch_array($result))
			{
				?><input type="Checkbox" id="c[]"  value="servicess"> <?echo $row['servicess'];
				echo "<br />";
				
				}
	  }
else
{
	?>
	other services<input type="Text" name="otherservices" 																id="otherservices" maxlength="30" value="" class="text" " >&nbsp;<span class="error_text" style="vertical-align:top;color:red">*</span>
	<?
}
mysql_close();

?>
Comments
use [code] tags

Hi,

This script is displaying according to data in database not acoording to session variabls.

what actually you want to perform.

You can treat a session var just like a regular var, so creating a session array follows the same syntax as a regular array.

session_start();
$_SESSION['varname'] = array("cell0", "cell1", "cell2");
$_SESSION['varname'][] = "cell3";
$_SESSION['varname'][] = "cell4";
$_SESSION['varname'][5] = "cell5";
$_SESSION['varname'][6] = "cell6";
print_r($_SESSION['varname']);

output = "Array ( [0] => cell0 [1] => cell1 [2] => cell2 [3] => cell3 [4] => cell4 [5] => cell5 [6] => cell6 ) "

Oh and session_register is deprecated anyway so you probably ought to do it this way.

Instead of having if-else if-else loop, why don't you assign these values to the dropdown list and then use a single query ?

This article has been dead for over six months. Start a new discussion instead.