<?php
$host = 'localhost';
$username = 'root';
$password = 'root';
$dbname = 'test';
$mysql = new Mysqli($host, $username, $password);
if($mysql -> connect_errno){
die('数据库连接失败:'.$mysql->connect_errno);
}else{
$mysql -> select_db($dbname); // 选择名为 test 的数据库
$sql = 'select name,sex,age from user'; // SQL 语句
$result = $mysql -> query($sql); // 执行上面的 SQL 语句
$data = $result -> fetch_all();
$mysql -> close();
}
echo '<pre>';
print_r($data);
?>
欢迎光临 艾Q网 (http://www.iqiok.com/bbs/) | Powered by Discuz! X3.4 |