First comb the operation idea:
List all data
Select the data record you want to modify to enter the editable state.
Submit Modification Results Complete modification
The data in the database is listed first, and a modify is added before each record, so that the user can select the records that they want to modify view.php.
Copy Code code as follows:
<?php
$link =mysql_connect ("localhost", "root", "admin password");
mysql_select_db ("Infosystem", $link);
$q = "SELECT * from Info";
mysql_query ("SET NAMES GB2312");
$rs = mysql_query ($q, $link);
echo "<table>";
echo "<tr><td> department name </td><td> employee name </TD><TD>PC name </td></tr>";
while ($row = Mysql_fetch_row ($rs)) echo "<tr><td><a href= ' modify_do.php?id= $row [0] ' >modify</a ></td><td> $row [1]</td><td> $row [2]</td><td> $row [3]</td><td>$ row[4]</td><td> $row [5]</td><td> $row [6]</td><td> $row [7]</td><td > $row [8]</td><td> $row [9]</td><td> $row [10]</td><td> $row [11]</td> <td> $row [12]</td><td> $row [13]</td></tr> ";
echo "</table>";
?>
When the user clicks Modify, enter the editable state of the corresponding record modify_do.php:
Copy Code code as follows:
<?php
$link =mysql_connect ("localhost", "root", "admin password");
if (! $link) {die ("error");}
echo "Connect MySQL successfully";
mysql_select_db ("Infosystem", $link);
$del _id=$_get["id"];
$q = "SELECT * from info where id= $del _id";
mysql_query ("SET NAMES GB2312"); Code Conversion
$rs = mysql_query ($q, $link);
if (! $rs) {die ("No results Displayed");}
?>
<body>
<form action= "modify_finish.php" method= "POST" >
<?php
echo "<input type= ' text ' size=25 name= ' id ' value= ' $del _id ' >";
while ($row = Mysql_fetch_object ($rs)) echo "<input type= ' text ' size=25 name= ' ename ' value= ' $row->ename ' >";
Mysql_close ($link); Closing datasets
?>
<input type= "Submit" Name= "submitted" value= "Submit" >
</form>
</body>
Finally, process the submit data modify_finish.php:
Copy Code code as follows:
<?php
$link =mysql_connect ("localhost", "root", "admin password");
if (! $link) {die ("error");}
echo "Connect MySQL successfully";
mysql_select_db ("Infosystem", $link);
mysql_query ("SET NAMES GB2312");
$rs = mysql_query ($q, $link);
$row = Mysql_fetch_object ($RS);
$exec = "Update info set ename= '". $_post[' ename '. "' where id= '. $_post[' id ']." "; Modify the data and add the last update time
echo "Modify success!"
Mysql_close ($link); Closing datasets
?>
Author: Sunec
Original download: Cenus Blog
All rights reserved. Reprint must be linked to the form of the author and the original source and this statement.