First, sort out the operation ideas:
List all data
Select the data record that needs to be modified and enter the editable state.
Submit the modification results to complete the modification
First list the data view.php in the database, and add the word "modify" before each record, so that users can select the records they want to modify for modification.
Copy code The code is as follows:
$link=mysql_connect("localhost","root ","Administrator password");
mysql_select_db("infosystem", $link);
$q = "SELECT * FROM info";
mysql_query("SET NAMES GB2312");
$rs = mysql_query($q, $link);
echo "
";
echo "Department name | Employee name | PC name |
";
while($row = mysql_fetch_row($rs)) echo "< ;a href='modify_do.php?id=$row[0]'>modify | $row[1] | $row[ 2] | $row[3] | $row[4] | $row[5] | < ;td>$row[6]$row[7] | $row[8] | $row[9] | $row[10] | $row[11] | $row[12] | |
";
echo "
";
?>
When the user clicks modify, enter the editable state of the corresponding record modify_do.php:
Copy code The code is as follows:
$link =mysql_connect("localhost","root","admin password");
if(!$link){die("error"); }
echo "Connect to 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");}
?>
Finally, process the submission Data modify_finish.php:
Copy code The code is as follows:
$link =mysql_connect("localhost","root","administrator password");
if(!$link){die("error");}
echo "Connect to 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 Data and add the last update time
echo "Modification successful!" ;
mysql_close($link); //Close the data set
?>
Author: Sunec
Original Published by: Cenus Blog
All rights reserved. When reprinting, the author, original source and this statement must be indicated in the form of a link.
http://www.bkjia.com/PHPjc/319134.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/319134.htmlTechArticleFirst, sort out the operation ideas: List all data, select the data records that need to be modified, and enter the editable state. Submit the modification results to complete the modification. First list the data views in the database....