$mysqli=new mysqli('127.0.0.1', 'root', 'password', "dbname");
if (mysqli_connect_errno()){ //注意mysqli_connect_error()新特性
die('Unable to connect!'). mysqli_connect_error();
}
$sql = "SET NAMES ".$charName;
$mysqli->query($sql);
$sql=' select * from table ;
try{
$rs=$mysqli->query($sql);
while($row = $rs->fetch_array(MYSQL_ASSOC)){
$a= $row['cishu1'];
$b= $row['cishu2'];
$c= $row['cishu3'];
$d= $row['cishu4'];
$1= $row['cishu5'];
}
}catch (Exception $e){
echo "不成功 ". $e->getMessage();
}
?>
甭管你有多少数据都要用
PDOStatement::fetch来读取
至于怎么用,官方手册有详细的例子就不贴了。