当前位置:网站首页>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
边栏推荐
- Hack the box optimum
- 全局、独享、局部路由守卫
- After idea is successfully connected to H2 database, there are no sub files
- Understanding process (multithreading primary)
- 每日一题(2022-04-21)——山羊拉丁文
- 机器学习(周志华) 第十四章概率图模型
- Daily question (April 22, 2022) - rotation function
- Niuke hand speed monthly race 48 C (I can't understand the difference. It belongs to yes)
- 解决 注册谷歌邮箱 gmail 手机号无法用于验证
- 16、 Anomaly detection
猜你喜欢
A domestic image segmentation project is heavy and open source!
[XJTU計算機網絡安全與管理]第二講 密碼技術
JVM类加载器
Global, exclusive and local routing guard
小程序 canvas 画布半圆环
本地远程访问云服务器的jupyter
day18--栈队列
Deploying sbert model based on torchserve < semantic similarity task >
一、序列模型-sequence model
Yes, from today on, our fans can participate in Netease data analysis training camp for free!
随机推荐
The 16th day of sprint to the big factory, noip popularization Group Three Kingdoms game
Fast and robust multi person 3D pose estimation from multiple views
RT_ Thread ask and answer
Class initialization and instance initialization interview questions
A domestic image segmentation project is heavy and open source!
JVM类加载器
基于Torchserve部署SBERT模型<语义相似度任务>
PHP sorting of interview questions on April 20, 2022
Preliminary understanding of stack and queue
go语言打怪通关之 ⌈互斥锁和状态协程⌋
智能辅助功能丰富,思皓X6安全配置曝光:将于4月23日预售
007_ Redis_ Jedis connection pool
【无标题】
Target narak
PTA: praise the crazy devil
Lighting LED of IAR embedded development stm32f103c8t6
Leetcode cooking
C语言中*与&的用法与区别 以及关键字static和volatile 的含义
Day18 -- stack queue
Implementation of distributed scenario business operation log (based on redis lightweight)