hi all,
i had a table and there are some users prsent in it. each user is having an edit button so now wen i click on edit button i could be able to edit that value means that label should turn as textbox with update cancel button so how can i do that please help me.

<?php
ob_start();
@session_start();
require_once ("check.php");
include 'connection.php';
$query= mysql_query("SELECT * FROM users where reportingto='$_SESSION[username]' and role='2'");
mysql_error();
$num=mysql_num_rows($query);
 ?>
<html>
<body>
<table border="1" cellspacing="0" cellpadding="0" align="center" style="width: 500px" bordercolor="red">
	<tr>
		<th style="color: navy;">Userid</th>
		<th style="color: navy;">Username</th>
		<th style="color: navy;">Password</th>
		<th style="color: navy;">Role</th>
		<th style="color: navy;">Status</th>   
	</tr>
<?php
$i=0;
while ($i < $num){
$f1=mysql_result($query,$i,"userid");
$f2=mysql_result($query,$i,"username");
$f3=mysql_result($query,$i,"password");
$f4=mysql_result($query,$i,"role");
if($f4 == 0)
   $f4 = 'Super Admin';
elseif($f4== 1)
   $f4 = 'Admin';
else
   $f4= 'User';   
$f5=mysql_result($query,$i,"status");
if($f5 == 1)
   $f5 = 'Active';
else
   $f5 = 'Inactive';

   ?>   
 <tr>
    
	<td><?php echo $f1;?></td>
	<td><?php echo $f2; ?></td>
	<td><?php echo $f3; ?></td>
	<td><?php echo $f4; ?></td>
	<td><?php echo $f5; ?></td>
	<td>edit</td>
<?php
$i++;
}
?>
</table>
</body>
</html>

Well there are many ways of doing this. The quick and dirty way of doing this is wrap a form around the table. Change edit to a submit button and store the username in the name attr so you can post it on the next file. Then do a db call to call that one record and set your html up to your liking. Again it is a quick and dirty way

<form method="post" action="somefilename.php">
<table border="1" cellspacing="0" cellpadding="0" align="center" style="width: 500px" bordercolor="red">
	<tr>
		<th style="color: navy;">Userid</th>
		<th style="color: navy;">Username</th>
		<th style="color: navy;">Password</th>
		<th style="color: navy;">Role</th>
		<th style="color: navy;">Status</th>   
	</tr>
<?php
$i=0;
while ($i < $num){
$f1=mysql_result($query,$i,"userid");
$f2=mysql_result($query,$i,"username");
$f3=mysql_result($query,$i,"password");
$f4=mysql_result($query,$i,"role");
if($f4 == 0)
   $f4 = 'Super Admin';
elseif($f4== 1)
   $f4 = 'Admin';
else
   $f4= 'User';   
$f5=mysql_result($query,$i,"status");
if($f5 == 1)
   $f5 = 'Active';
else
   $f5 = 'Inactive';

   ?>   
 <tr>
    
	<td><?php echo $f1;?></td>
	<td><?php echo $f2; ?></td>
	<td><?php echo $f3; ?></td>
	<td><?php echo $f4; ?></td>
	<td><?php echo $f5; ?></td>
	<td><input type="submit" name="<?php echo $f1; ?>" value="edit" /></td>
<?php
$i++;
}
?>
</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.