当前位置:网站首页>Add, delete, modify and query curd in PHP native SQL
Add, delete, modify and query curd in PHP native SQL
2022-06-26 04:17:00 【Never bow】
Reprint https://blog.csdn.net/weixin_43993175/article/details/104961925
<?php
header("Content-type: text/html; charset=utf-8");
$ip = $_REQUEST['ip']; //ip
$time = time(); // Creation time
$content = $_REQUEST['content']; // Content
// Connect to database database host Address account number password Table name
$conn = mysqli_connect("localhost", 'root', "root", 'bd');
// Query the database
$sql = "select * from bd where ip = '$ip' order by id desc LIMIT 1";
$query = $conn->query($sql);
//$a=[];
while ($row = $query->fetch_array()) {
echo $row['id'], '<br>';
//array_push($a,$row);
}
// insert data
$sql = "insert into bd (ip,time,content) value ('$ip','$time','$content')";
$result = mysqli_query($conn, $sql);
// Modifying data
$sql = "UPDATE table_name SET field1=new-value1, field2=new-value2";
$result = mysqli_query($conn, $sql);
if(!$result)
{
die(' Unable to update data : ' . mysqli_error($conn));
}
// Delete data
$sql = "DELETE FROM runoob_tbl WHERE runoob_id=3";
$result = mysqli_query($conn, $sql);
边栏推荐
- Syntax error of go language generic in IDE
- How do wechat applets delay? Timing? Execute a piece of code after? (kengji)
- Knowledge of functions
- [geek challenge 2019] rce me
- VHDL design
- Upload script file (one sentence back door) WAF bypass (PHP)
- BSC 及HT 等链的NFT 创造及绑定图片教程
- How does virtual box virtual machine software accelerate the network speed in the virtual system?
- Nailing open platform - applet development practice (nailing applet server side)
- 线程同步之互斥量(互斥锁)
猜你喜欢

【掘金运营套路揭露】真心被掘金的套路....

Oracle technology sharing Oracle 19.14 upgrade 19.15

In 2022, what professional competitions can college students majoring in automation, electrical engineering and automation participate in?

Matplotlib multi line chart, dot scatter chart

Detailed explanation of globalkey of flutter

(15) Blender source code analysis flash window display menu function

What's wrong with connecting MySQL database with eclipse and then the words in the figure appear

Dix critères de base importants pour les essais de débogage de logiciels

Getting started with flask

Sorting out the examination sites of the 13th Blue Bridge Cup single chip microcomputer objective questions
随机推荐
In the matter of getting customers at sea, how can advertisers play besides digital advertising?
Go SQL parsing time Time type
[Flink] Flink batch mode map side data aggregation normalizedkeysorter
一幅脑图总结一下需求分析(工作上实际遇到的情况的补充)
The stc-isp burning program for 51 single chip microcomputer always shows that "the target single chip microcomputer is being detected..." the cold start board does not respond
线程同步之读写锁
Li Kou 79 word search
SQL related knowledge - DQL
Parse JSON interface and insert it into the database in batch
Capture packets (Wireshark)
asp.net网页选择身份进行登录的简单代码,asp连接数据库,使用asp:Panel、asp:DropDownList控件
Sorting out the examination sites of the 13th Blue Bridge Cup single chip microcomputer objective questions
Minecraft 1.16.5 生化8 模组 1.9版本 1.18版本同步
What are the advantages and risks of paper gold investment
Zeromq from getting started to mastering
Oracle technology sharing Oracle 19.14 upgrade 19.15
Quanergy welcomes Lori sundberg as chief human resources officer
Swagger
MySQL enable logbin in Qunhui docker
Principle and implementation of syn cookie