4 回答
TA贡献81条经验 获得超102个赞
header("content-type:text/html;charset=utf-8");
$mysqli=new mysqli("localhost","root", "","test");
if($mysql->connect_errno){
die("connect error:".$mysqli->connect_error);
}
$mysqli->set_charset('utf8');
$sql = "SELECT id,username,age FROM user";
$mysqli_result= $mysqli->query($sql); //返回值在$mysqli_result中,$mysqli->query()只能读取一个记录
循环显示
while($row = $mysqli_result->fetch_assoc()){
$rows[] = $row;//二维数组
}
$mysqli_result->free();
$mysqli->close();
$rows数组就是你想要的二维数组
TA贡献2条经验 获得超3个赞
<?php
header("Content-Type:text/html; charset=utf-8");
$arr=array(
"('A','女',21)",
"('B','男',23)",
"('C','男',24))"
);
$a=array(
$arr
);
print_r($a);
?>
TA贡献38条经验 获得超6个赞
<?php
header("Content-Type:text/html; charset=utf-8");
$A=('A','女',21);
$B=('B','男',23);
$C=('C','男',24));
$arr=array(
$A,
$B,
$C
);
print_r($arr);
?>
- 4 回答
- 0 关注
- 1605 浏览
添加回答
举报