<?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);//关闭连接
?>
相关文章
- 云栖神侠传—阿里云数据库专家德歌告诉你PostgreSQL的那些事
- MYSQL数据库的常用数据类型
- 解决Oracle ORA-01033: ORACLE initialization or shutdown in progress错误 和 ORA-01589错误 要打开数据库则必须使用 RESETLOGS 或 NORESETLOGS 选项
- Swoole 4.1.0 正式版发布,支持原生 Redis/PDO/MySQLi 协程化
- (转) java 通过 jdbc 链接 ms sql server 中出现 "no suitable driver for ..."
- 微软推荐的Get a code signing certificate流程和链接
- sql server数据库操作
- 现在的SQLSERVER数据库监控软件有哪些?
- AspNet Core :创建自定义 EF Core 链接数据库
- spring boot 数据库连接池配置