<?php
$uid = $_GET['uid'];
$host = 'localhost';
$database = 'test';
$username = 'root';
$password = '123456789';
$selectName = 'harry';//要查找的用户名,一般是用户输入的信息
$insertName = 'testname';
$connection = mysqli_connect($host, $username, $password,$database);//连接到数据库
if (!$connection) {
die("could not connect to the database.\n" . mysqli_content_error());//诊断连接错误
}
$query = "select * from tp_users where uid =" . $uid;//构建查询语句
$result = mysqli_query($connection,$query);//执行查询
if (!$result) {
die("could not to the database\n" . mysqli_content_error());
}
while ($row = mysqli_fetch_row($result)) {
print_r($row);
}
//添加记录
// $insertSql = "insert into tp_users(name, age) values('$insertName', 18)";
// $result = mysqli_query($connection,$insertSql);
// echo $result . "\n";
//更新记录
// $updateSql = "update user set uid = 3 where name=2";
// $result = mysqli_query($connection,$updateSql);
// echo $result . "\n";
//删除记录
// $deleteSql = "delete from user where uid = 3";
// $result = mysqli_query($connection,$deleteSql);
// echo $result . "\n";
mysqli_close($connection);//关闭连接
?>
相关文章
- 代码创建数据库_表--SqlServer数据库
- 链接渐变效果
- 第二章:配置邮箱数据库邮件地址列表公共文件夹
- Java:SpringBoot整合MyBatis-Plus实现MySQL数据库的增删改查
- 数据库必知必会:TiDB(3)TiKV持久化
- 【眼见为实】自己动手实践理解数据库REPEATABLE READ && Next-Key Lock
- 【眼见为实】自己动手实践理解数据库READ UNCOMMITED && SERIALIZABLE
- 【眼见为实】自己动手实践理解数据库READ COMMITTED && MVCC
- k8s部署canal-1.1.6版本实现MySQL数据库数据同步
- PG数据库服务器的CPU使用率突然升高该如何分析