当前位置:网站首页>Modify the content of MySQL + PHP drop-down box
Modify the content of MySQL + PHP drop-down box
2022-04-23 02:37:00 【Colored sponge】
Based on the previous search drop-down box , After the content is added to the specific location , Then modify it .
<?php
error_reporting(0);// add error_reporting(0); No warning will pop up
header("Content-type:text/html;charset=utf-8");// Prevent Chinese miscoding
$con = mysqli_connect("localhost","root"," password "," Linked database name ");
mysqli_query($con,'set names utf8');
if (!$con){
echo' Failed to link database !';
}
?>
<!DOCTYPE html>
<html>
<head></head>
<body>
<form action="" method="get" > //action If it is empty, it means form Submit form to current page
<select name="id" >
<option > Please select </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=" Submit ">
</form>
<?php
$id = $_GET["id"];
// according to id Find the data to be operated at present
$sql= "select * from userinfo where id = '$id'";
// Inquire about
$result=$con->query($sql);
// var_dump($result);//dedao
// Get specific information
$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> Modified user name </b></label>
<input type="text" value="<?php echo $res['username'];?> " name="username">
<label><b> User password </b></label>
<input type="text" value="<?php echo $res['password'];?> " name="password" >
<label><b> User level :</b></label>
<input type="text" value="<?php echo $res['level'];?> " name="level">
<button type="submit" name="" > Modify the information </button>
</form>
<?php
// modify php Code
$id = $_GET["id"];
$user = $_GET['username'];
$pwd = $_GET['password'];
$level = $_GET['level'];
// according to id Find the data to be operated at present
$sql= "update userinfo set username = '$user', password ='$pwd',level='$level' WHERE id = '$id'";
// perform
$result=$con->query($sql);
?>
</body>
</html>
版权声明
本文为[Colored sponge]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204230236378198.html
边栏推荐
- They are all intelligent in the whole house. What's the difference between aqara and homekit?
- leetcode 烹饪料理
- 一个国产图像分割项目重磅开源!
- 下载正版Origin Pro 2022 教程 及 如何 激 活
- JVM运行时数据区(一)
- MySQL JDBC编程
- Tp6 Alibaba Cloud SMS Window message Curl Error 60: SSL Certificate Problem: Unable to get local issuer Certificate
- 每日一题(2022-04-22)——旋转函数
- 002_ Redis_ Common operation commands of string type
- go语言打怪通关之 ⌈互斥锁和状态协程⌋
猜你喜欢

Jupyter for local and remote access to ECS

Applet canvas canvas half ring

期中汇总(概论+应用层+运输层)

arduino esp8266 网络升级 OTA

How big the program development of single chip microcomputer project can be, it represents your level of knocking code

New book recommendation - IPv6 technology and application (Ruijie version)
![[xjtu Computer Network Security and Management] session 2 Cryptographic Technology](/img/b0/263e8dcbfeb2ce9f504a9c8eb76b07.png)
[xjtu Computer Network Security and Management] session 2 Cryptographic Technology
![PTA: 浪漫倒影 [二叉树重建] [深度优先遍历]](/img/ae/a6681df6c3992c7fd588334623901c.png)
PTA: 浪漫倒影 [二叉树重建] [深度优先遍历]

Flink stream processing engine system learning (III)

十六、异常检测
随机推荐
C语言中*与&的用法与区别 以及关键字static和volatile 的含义
Implementation of distributed scenario business operation log (based on redis lightweight)
R language advanced | generalized vector and attribute analysis
想用Mac学习sql,主要给自己个充足理由买Mac听听意见
Day 4 of learning rhcsa
They are all intelligent in the whole house. What's the difference between aqara and homekit?
数仓建表111111
010_ StringRedisTemplate
WordPress calls the specified page content. 2 get_ children()
Suggestion: block reference sorting is in the order of keywords
New book recommendation - IPv6 technology and application (Ruijie version)
Handwritten memory pool and principle code analysis [C language]
十六、异常检测
牛客手速月赛 48 C(差分都玩不明白了属于是)
Synchronized lock and its expansion
002_ Redis_ Common operation commands of string type
认识进程(多线程_初阶)
打靶narak
谷雨
Halo open source project learning (I): project launch