Code: Select all
<html>
<body>
<table border="1">
<tr><th>Dept ID</th><th>Dept Name</th><th>Modify</th></tr>
<?php
$conn=mysql_connect("localhost", "fierm", "13183");
if (!$conn){
echo "failed";
}else{
mysql_select_db("fierm");
$result=mysql_query("SELECT DeptID, DeptName FROM department");
while($row=mysql_fetch_array($result)){
$strUrl="<a href=\"second.php?id=$row[0]&dp=$row[1]\">Edit</a>";
echo "<tr><td>$row[0]</td><td>$row[1]</td><td>$strUrl</td></tr>\n"; }
}
mysql_free_result($result);
mysql_close($conn);
?>
</table>
</body>
</html>
Code: Select all
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Untitled</title>
</head>
<?php
$Conn=mysql_connect("localhost","fierm","13183");
mysql_select_db("fierm");
$DeptID= $_GET["id"];
$DeptName=$_GET["dp"];
?>
<body>
<form action="third.php" method="post">
ID:
<input id="id" type="text" readonly="true" value="<?php echo $_GET["id"];?>"/><br />
Department:<input id="dp" type="text" value="<?php echo $_GET["dp"]?>"/><br />
<br />
<input id="Submit1" type="submit" value="submit" /><br />
</form>
</body>
</html>
Code: Select all
<?php
$Conn=mysql_connect("localhost","fierm","13183");
mysql_select_db("fierm");
$new=$_GET["dp"];
$id= $_GET["id"];
$result=mysql_query("Update department SET DeptName ='$new' WHERE DeptID='$id'");
if($result){
echo "one record is updated";
}else{
echo "cannot update the record";
}
?>