<?php
$conn = mysqli_connect("127.0.0.1","root","root",'baixiu');
$sql = "select * from users";
$res = mysqli_query($conn,$sql);
print_r($res);
while($row = mysqli_fetch_assoc($res)){
$arr[] = $row;
}
echo "<hr>";
print_r($arr);
?>
print_r($res) :
mysqli_result Object | |
( | |
[current_field] => 0 | |
[field_count] => 8 | |
[lengths] => | |
[num_rows] => 4 | |
[type] => 0 | |
) |
print_r($arr) : 得到二维数组
Array | |
( | |
[0] => Array | |
( | |
[id] => 1 | |
[slug] => admin | |
[email] => [email protected] | |
[password] => wanglei | |
[nickname] => 绠$悊鍛� | |
[avatar] => /static/uploads/avatar.jpg | |
[bio] => | |
[status] => activated | |
) | |
[1] => Array | |
( | |
[id] => 2 | |
[slug] => zce | |
[email] => [email protected] | |
[password] => wanglei | |
[nickname] => 姹 | |
[avatar] => /static/uploads/avatar.jpg | |
[bio] => | |
[status] => unactivated | |
) | |
[2] => Array | |
( | |
[id] => 3 | |
[slug] => ice | |
[email] => [email protected] | |
[password] => wanglei | |
[nickname] => 姹 | |
[avatar] => /static/uploads/avatar.jpg | |
[bio] => | |
[status] => activated | |
) | |
[3] => Array | |
( | |
[id] => 4 | |
[slug] => qq | |
[email] => [email protected] | |
[password] => goudan | |
[nickname] => 鏉庣嫍铔� | |
[avatar] => /static/uploads/widget_3.jpg | |
[bio] => | |
[status] => activated | |
) | |
) |