PHP Example
Screen shot
Screen shot
index.php

<?php
$conn=mysql_connect(\'localhost\',\'root\',\'\') or die(\'Not connected\');

$database=mysql_select_db(\'student\',$conn) or die(\'Database Not connected\');

$query=\"SELECT * FROM info\";
$data=mysql_query($query);
echo \"<table border=\'1\'>\";
echo \"<tr>\";
echo \"<th>Fname</th>\";
echo \"<th>Lname</th>\";
echo \"<th>Edit</th>\";
echo \"</tr>\";
while($result=mysql_fetch_array($data))
{
echo \"<tr>\";
echo \"<td>$result[1]</td>\";
echo \"<td>$result[2]</td>\";
echo \"<td><a href=\"edit.php?id=$result[0]\">Edit</a></td>\";
echo \"</tr>\";
}
echo \"</table>\";
?>

edit.php

<?php
$conn=mysql_connect(\'localhost\',\'root\',\'\') or die(\'Not connected\');

$database=mysql_select_db(\'student\',$conn) or die(\'Database Not connected\');

$id=$_REQUEST[\'id\'];

$query=\"SELECT * FROM info where id=$id\";
$data=mysql_query($query);
$result=mysql_fetch_array($data);
echo \"<form name=\'frm\' action=\'update.php\' method=\'post\'>\";
echo \"<table border=\'1\'>\";
echo \"<tr>\";
echo \"<td>First Name</td>\";
echo \"<td>
<input name=\'id\' type=\'hidden\' value=\'$result[0]\'/>
<input name=\'fname\' type=\'text\' value=\'$result[1]\'/></td>\";
echo \"</tr>\";
echo \"<tr>\";
echo \"<td>Last Name</td>\";
echo \"<td><input name=\'lname\' type=\'text\' value=\'$result[2]\'/></td>\";
echo \"</tr>\";
echo \"<tr>\";
echo \"<td>Email</td>\";
echo \"<td><input name=\'email\' type=\'text\' value=\'$result[3]\'/></td>\";
echo \"</tr>\";
echo \"<tr>\";
echo \"<td>Country</td>\";
echo \"<td><input name=\'country\' type=\'text\' value=\'$result[4]\'/></td>\";
echo \"</tr>\";
echo \"<tr>\";
echo \"<td>&nbsp;</td>\";
echo \"<td><input name=\'update\' type=\'submit\' value=\'UPDATE\'/></td>\";
echo \"</tr>\";
echo \"</form>\";
?>

update.php

<?php

if(isset($_POST[\'update\']))
{
$conn=mysql_connect(\'localhost\',\'root\',\'\') or die(\'Not connected\');

$database=mysql_select_db(\'student\',$conn) or die(\'Database Not connected\');

$id=$_POST[\'id\'];
$fname=$_POST[\'fname\'];
$lname=$_POST[\'lname\'];
$email=$_POST[\'email\'];
$country=$_POST[\'country\'];

$query=\"update info set fname=\'$fname\',lname=\'$lname\',email=\'$email\',country=\'$country\'
where id=\'$id\'\";

mysql_query($query);

header(\"Location:test8.php\");

}
?>

You can download source code here