This article mainly shares with you how to update database data in PHP. Hope it helps everyone.
The first step is to create the update page file Upwork.php
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>删除</title> </head> <body> <h1 style='font-size:18px;text-align:center;'>修改数据</h1>
<?php $code = $_GET["code"]; $db = new MySQLi("localhost","root","123456","study"); !mysqli_connect_error() or die("连接失败!"); $sql1 = "select * from `员工信息` where 工号='{$code}'"; $r1 = $db->query($sql1); $att1 = $r1->fetch_row(); ?> <form action="UpworkChuLi.php" method="post"> <p style='text-align:center;'> <p style='margin:10px;'>员工工号:<input readonly="readonly" name="code" value="<?php echo $att1[0];?>" /></p> <p style='margin:10px;'>员工姓名:<input type="text" name="name" value="<?php echo $att1[1];?>" /></p> <p style='margin:10px;'>出生日期:<input type="text" name="date" value="<?php echo $att1[2];?>"></p> <p style='margin:10px;'>员工年龄:<input type="text" name="age" value="<?php echo $att1[3];?>" /></p> <p style='margin:10px;'>员工职称:<input type="text" name="job" value="<?php echo $att1[4];?>" /></p> <p style='margin:10px;'>所在部门:<input type="text" name="department" value="<?php echo $att1[5];?>"></p> <p style='margin:10px;'>员工月薪:<input type="text" name="month" value="<?php echo $att1[6];?>" /></p> <p style='margin:10px;'>员工年薪:<input type="text" name="year" value="<?php echo $att1[7];?>" /></p> <p style='margin:10px;'>政治面貌:<input type="text" name="politics" value="<?php echo $att1[8];?>"></p> <p style='margin:10px;'>健康状况:<input type="text" name="health" value="<?php echo $att1[9];?>"></p> <p><input type="submit" value="修改数据" /></p> </p> </form> </body>