当前位置:网站首页>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
边栏推荐
- Interpretation of the future development of smart agriculture
- Real math problems in 1958 college entrance examination
- 16、 Anomaly detection
- Solve the problem that the registered Google email Gmail mobile number cannot be used for verification
- [XJTU计算机网络安全与管理]第二讲 密码技术
- 002_ Redis_ Common operation commands of string type
- A domestic image segmentation project is heavy and open source!
- PIP install shutil reports an error
- Wechat public platform test number application, authorized login function and single sign on using hbuilder X and wechat developer tools
- They are all intelligent in the whole house. What's the difference between aqara and homekit?
猜你喜欢

Talk about current limiting

【unity3D】直播间滚动式弹幕效果

每日一题冲刺大厂第十六天 NOIP普及组 三国游戏

【无标题】

Talk about biology live broadcast: Dr. Wang Ziyuan, a lake view biology, exploring hepatitis B with gene therapy

Rhcsa day 1 operation

认识进程(多线程_初阶)

Halo open source project learning (I): project launch

006_ redis_ Sortedset type

全局、独享、局部路由守卫
随机推荐
PTA: praise the crazy devil
SO库依赖问题
认识进程(多线程_初阶)
Preliminary understanding of stack and queue
C语言 171. 最近回文数
基于Torchserve部署SBERT模型<语义相似度任务>
每日一题(2022-04-22)——旋转函数
Efficient music format conversion tool Music Converter Pro
每日一题(2022-04-21)——山羊拉丁文
JSP page nesting
Lighting LED of IAR embedded development stm32f103c8t6
006_ redis_ Jedis quick start
LeetCode 349. Intersection of two arrays (simple, array) Day12
Tp6 Alibaba Cloud SMS Window message Curl Error 60: SSL Certificate Problem: Unable to get local issuer Certificate
First day of rhcsa
Consider defining a bean of type ‘com.netflix.discovery.AbstractDiscoveryClientOptionalArgs‘
C语言中*与&的用法与区别 以及关键字static和volatile 的含义
定了,今日起,本号粉丝可免费参与网易数据分析培训营!
hack the box optimum靶机
After idea is successfully connected to H2 database, there are no sub files