php mysql 查询
时间:2021-07-01 10:21:17
帮助过:19人阅读
//1:创建连接
$conn =
mysqli_connect("127.0.0.1","root","","dangdang"
);
//2:设置编码
mysqli_query(
$conn,"SET NAMES UTF8"
);
//3:创建sql,发送sql
$sql = "SELECT * FROM dd_book"
;
$result =
mysqli_query(
$conn,
$sql);
//4:获取返回结果
//5:抓取一行记录 关联数组
while(
$row =
mysqli_fetch_assoc(
$result)){
echo $row[‘id‘].
$row[‘title‘].‘<br/>‘
;
}
//6: 抓取一行记录,索引数组
//while($row = mysqli_fetch_row($result)){
// echo $row[0].$row[1].‘<br />‘;
//}
?>
php mysql 查询
标签:blog 创建 返回 行记录 sel 索引 数组 query logs