当前位置:网站首页>php+mysql對下拉框搜索的內容修改
php+mysql對下拉框搜索的內容修改
2022-04-23 02:37:00 【彩色海綿】
基於上一篇搜索下拉框,內容添加到具體比特置後,再對其進行修改。
<?php
error_reporting(0);//加上error_reporting(0);就不會彈出警告了
header("Content-type:text/html;charset=utf-8");//防止中文亂碼
$con = mysqli_connect("localhost","root","密碼","鏈接的數據庫名稱");
mysqli_query($con,'set names utf8');
if (!$con){
echo'鏈接數據庫失敗!';
}
?>
<!DOCTYPE html>
<html>
<head></head>
<body>
<form action="" method="get" > //action為空就是form錶單提交給當前頁面
<select name="id" >
<option >請選擇</option>
<?php
$sql="select * from userinfo ";
$res=mysqli_query($con,$sql);
while($row=$res->fetch_assoc()){
//var_dump($row);
?>
<option>
<?php echo $row["id"];?>
<?php echo $row["username"];?>
</option>
<?php
}
?>
</select>
<input type="submit" value="提交">
</form>
<?php
$id = $_GET["id"];
//根據id查到當前要操作的數據
$sql= "select * from userinfo where id = '$id'";
//查詢
$result=$con->query($sql);
// var_dump($result);//dedao
//得到具體信息
$res = $result->fetch_assoc();
?>
<form action="" method="get" >
<br /><br /><br /><br /><br /><br />
<input type="hidden" value="<?php echo $res['id'];?> " name="id" >
<label><b>修改的用戶姓名</b></label>
<input type="text" value="<?php echo $res['username'];?> " name="username">
<label><b>用戶密碼</b></label>
<input type="text" value="<?php echo $res['password'];?> " name="password" >
<label><b>用戶級別:</b></label>
<input type="text" value="<?php echo $res['level'];?> " name="level">
<button type="submit" name="" >修改信息</button>
</form>
<?php
//修改php代碼
$id = $_GET["id"];
$user = $_GET['username'];
$pwd = $_GET['password'];
$level = $_GET['level'];
//根據id查到當前要操作的數據
$sql= "update userinfo set username = '$user', password ='$pwd',level='$level' WHERE id = '$id'";
//執行
$result=$con->query($sql);
?>
</body>
</html>
版权声明
本文为[彩色海綿]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204230236378198.html
边栏推荐
- 1、 Sequence model
- 谷雨
- Class initialization and instance initialization interview questions
- JDBC JDBC
- How to recognize products from the perspective of Dialectics
- [suggestion collection] hematemesis sorting out golang interview dry goods 21 questions - hanging interviewer-1
- 全局、独享、局部路由守卫
- Applet reads files
- 数仓建表111111
- Using go language to build web server
猜你喜欢
随机推荐
R language advanced | generalized vector and attribute analysis
Lighting LED of IAR embedded development stm32f103c8t6
Web learning record (medium)
Synchronized lock and its expansion
Leetcode cooking
JVM类加载器
tp6阿里云短信 window 报 cURL error 60: SSL certificate problem: unable to get local issuer certificate
Rich intelligent auxiliary functions and exposure of Sihao X6 security configuration: it will be pre sold on April 23
WordPress calls the specified page content. 2 get_ children()
[xjtu Computer Network Security and Management] session 2 Cryptographic Technology
If you want to learn SQL with a Mac, you should give yourself a good reason to buy a Mac and listen to your opinions
wordpress 调用指定页面内容详解2 get_children()
Kubernetes cluster installation based on Kirin SP10 server version
Latin goat (20204-2022) - daily question 1
[chrome extender] content_ Cross domain problem of script
Flink stream processing engine system learning (III)
Day 3 of learning rhcsa
定了,今日起,本号粉丝可免费参与网易数据分析培训营!
This is how the power circuit is designed
全局、独享、局部路由守卫