当前位置:网站首页>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
边栏推荐
- Flink stream processing engine system learning (I)
- First day of rhcsa
- Niuke hand speed monthly race 48 C (I can't understand the difference. It belongs to yes)
- R language advanced | generalized vector and attribute analysis
- 在MySQL Workbench中执行外部的SQL脚本,报错
- PTA: Romantic reflection [binary tree reconstruction] [depth first traversal]
- Flink stream processing engine system learning (II)
- 小程序 读取文件
- 魔王冷饭||#078 魔王答上海、南京行情;沟通指导;得国和打杀筛选;赚钱的目的;改变别人看法
- 下载正版Origin Pro 2022 教程 及 如何 激 活
猜你喜欢

The usage and difference of * and & in C language and the meaning of keywords static and volatile

SQL server2019 cannot download the required files, which may indicate that the version of the installer is no longer supported. What should I do

Global, exclusive and local routing guard

011_ Redistemplate operation hash

Day18 -- stack queue

Fast and robust multi person 3D pose estimation from multiple views

JVM运行时数据区(一)

Intelligent agricultural management model

Latin goat (20204-2022) - daily question 1
![[XJTU computer network security and management] Lecture 2 password technology](/img/b0/263e8dcbfeb2ce9f504a9c8eb76b07.png)
[XJTU computer network security and management] Lecture 2 password technology
随机推荐
The second day of learning rhcsa
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
Suggestion: block reference sorting is in the order of keywords
MySQL C language connection
能做多大的单片机项目程序开发,就代表了你的敲代码的水平
leetcode 烹飪料理
Synchronized lock and its expansion
Solve the problem that the registered Google email Gmail mobile number cannot be used for verification
After idea is successfully connected to H2 database, there are no sub files
[nk]牛客月赛48 D
Daily question (April 22, 2022) - rotation function
在MySQL Workbench中执行外部的SQL脚本,报错
Talk about biology live broadcast: Dr. Wang Ziyuan, a lake view biology, exploring hepatitis B with gene therapy
The 16th day of sprint to the big factory, noip popularization Group Three Kingdoms game
IAR embedded development stm32f103c8t6 Lighting LED
Efficient music format conversion tool Music Converter Pro
Day18 -- stack queue
JSP page nesting
Download the genuine origin Pro 2022 tutorial and how to activate it
Usage of vector common interface