当前位置:网站首页>php+mysql对下拉框搜索的内容修改
php+mysql对下拉框搜索的内容修改
2022-04-23 02:36: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://blog.csdn.net/m0_63172128/article/details/124214048
边栏推荐
- They are all intelligent in the whole house. What's the difference between aqara and homekit?
- 能做多大的单片机项目程序开发,就代表了你的敲代码的水平
- Common formatting problems after word writing
- SO库依赖问题
- tp6阿里云短信 window 报 cURL error 60: SSL certificate problem: unable to get local issuer certificate
- 1、 Sequence model
- hack the box optimum靶机
- Summary of I / O knowledge points
- 解决 注册谷歌邮箱 gmail 手机号无法用于验证
- [XJTU計算機網絡安全與管理]第二講 密碼技術
猜你喜欢
一、序列模型-sequence model
SQL server2019无法下载所需文件,这可能表示安装程序的版本不再受支持,怎么办了
谷雨
How to solve the complexity of project document management?
So library dependency
魔王冷饭||#078 魔王答上海、南京行情;沟通指导;得国和打杀筛选;赚钱的目的;改变别人看法
Wechat public platform test number application, authorized login function and single sign on using hbuilder X and wechat developer tools
每日一题冲刺大厂第十六天 NOIP普及组 三国游戏
使用Go语言构建Web服务器
New book recommendation - IPv6 technology and application (Ruijie version)
随机推荐
魔王冷饭||#078 魔王答上海、南京行情;沟通指导;得国和打杀筛选;赚钱的目的;改变别人看法
Hyperscan -- 2 compilation
Applet canvas canvas half ring
智能辅助功能丰富,思皓X6安全配置曝光:将于4月23日预售
MySQL JDBC programming
Synchronized lock and its expansion
Efficient music format conversion tool Music Converter Pro
想用Mac学习sql,主要给自己个充足理由买Mac听听意见
Jupyter for local and remote access to ECS
程序设计天梯赛 L1-49 天梯赛分配座位(模拟),布响丸辣
JDBC JDBC
New book recommendation - IPv6 technology and application (Ruijie version)
Arduino esp8266 network upgrade OTA
Go language ⌈ mutex and state coordination ⌋
[suggestion collection] hematemesis sorting out golang interview dry goods 21 questions - hanging interviewer-1
[XJTU计算机网络安全与管理]第二讲 密码技术
Parental delegation model [understanding]
SQL server2019 cannot download the required files, which may indicate that the version of the installer is no longer supported. What should I do
Day18 -- stack queue
Explain JS prototype and prototype chain in detail