This is my code can you expllain how the user may activate or inactivate with check box....

<?php 
mysql_connect("localhost","root","rootwdp");
mysql_select_db("rams");
if(isset($_REQUEST['submit']))

{
	$arr=$_REQUEST['chk'];
	foreach($arr as $key => $value)
	{
		
		$sql=mysql_query("update ram set status=1 where emp_id=$value");
	}
		 
		  $sql1="select * from ram where status=1";
		  $res1=mysql_query($sql1);
		  
?>   
   <form action="" method="post" name="form">
	<table border="1"><th>Username</th><th>Empid</th><th>Designation</th><th>Check box</th> 
	 <?php    
			   while($row1=mysql_fetch_array($res1))
		  {
	
				?> 	
               <tr>   
			<td><?php echo $row1[0];?></td>
		   
		   
	         <td align="center"><?php echo $row1[1];?></td>
		
	
			  <td align="center"> <?php echo $row1[2];?> </td>
			<td align="center">
	<input type="hidden" name="chk" id="chk" value="<?php $row1[1];?>"/>
	<input type="checkbox" id="chk" name="chk"  value="<?php $row1[1];?>"  />
	</td>
			  
			  
		   </tr>
		
		   <?php }
		   } ?>
		</table></form>
		
<?php
mysql_connect("localhost","root","rootwdp");
mysql_select_db("rams") or die("unable to select");
 $query = "SELECT * FROM `ram`";
 $dd=mysql_query($query);
	
   ?>

   
<form action="" method="post" name="form">
   	<table border="1"><th>Username</th><th>Empid</th><th>Designation</th><th>Check box</th> 
	 <?php    
			   while( $row=mysql_fetch_array($dd))
				{
				?> 	
               <tr>   
			<td><?php echo $row[0];?></td>
		   
		   
	         <td align="center"><?php echo $row[1];?></td>
		
	
			  <td align="center"> <?php echo $row[2];?> </td>
	<td><input type="hidden" name="chk" id="chk" value="<?php $row[1];?>"/>
	    <input type="checkbox" id="chk" name="chk"  value="<?php $row[1];?>"/></td>
			  
			  
		   </tr>
		
		   <?php } ?>
		</table>
		<table><tr><td> <input type="submit" name="submit" value="Submit" /></td></tr></table>
		</form>

Hi...
Why are you giving two controls the same name..
One is checkbox and other hidden field...

Just put one control...
Use checkbox and give it name as chk[] ... Yes you read right.. Its an array.. Secondly.. give its value as user's id or name (basically the field from which you will search the user in the database..

<?php 
mysql_connect("localhost","root","rootwdp");
mysql_select_db("rams");

if($_REQUEST['submit'] == "Activate")
{
	$arr=$_REQUEST['chk'];
	
	$empids = implode(",",$arr);

	// This will transform your array into a string with empids separated by comma e.g. 1,2,5,7

	mysql_query("update ram set status=1 where emp_id in $empids");
	//this will set all employee ids in one go..
}

if($_REQUEST['submit'] == "Deactivate")
{
	$arr=$_REQUEST['chk'];
	
	$empids = implode(",",$arr);

	// This will transform your array into a string with empids separated by comma e.g. 1,2,5,7

	mysql_query("update ram set status=0 where emp_id in $empids");
	//this will set all employee ids in one go..
}




	$query = "SELECT * FROM `ram`";
	$dd=mysql_query($query);
	
	?>

   
	<form action="" method="post" name="form">
   	<table border="1"><th>Username</th><th>Empid</th><th>Designation</th><th>Check box</th> 
	 <?php    
			   while( $row=mysql_fetch_array($dd))
				{
				?> 	
               <tr>   
			<td><?php echo $row[0];?></td>
		   
		   
	         <td align="center"><?php echo $row[1];?></td>
		
	
			  <td align="center"> <?php echo $row[2];?> </td>
	<td><input type="checkbox" id="chk[]" name="chk[]"  value="<?php $row[1];?>"/></td>
			  
			  
		   </tr>
		
		   <?php } ?>
		</table>

		<table>
			<tr>
				<td> <input type="submit" name="submit" value="Activate" /></td>
				<td> <input type="submit" name="submit" value="Deactivate" />
		</tr></table>

		</form>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.