$sql = "SELECT active FROM table_name";
$result = $conn->query($sql);
DB:
|active|
1
1
0
1
我有这样的表,需要将这些行放入数组中。 是否可以像这样得到简单的数组?:
$array = (1,1,0,1);
感谢
答案 0 :(得分:1)
$sql = "SELECT active FROM table_name";
$result = $conn->query($sql);
$arr=array();
foreach($result as $res)
{
array_push($arr,$res->active);
}
var_dump($arr);
答案 1 :(得分:0)
$sql = "SELECT active FROM table_name";
$result = $conn->query($sql);
while($row = $result->fetch_assoc()) {
$arr[]= $row['active'];
}
print_r($arr);