我有将 mysqli 查询的结果存储在数组中的代码,但我想通过仅将一列的结果存储在数组中来使代码更高级。这是我的代码:
// Create array of devices that match the current unit in array $unitsarray
$result = $mysqli->query("SELECT * FROM `department devices` WHERE unit LIKE $unit");
//Fetch all rows in result and store them in an array $rows
$rows = array();
while($row = $result->fetch_row()) {
$rows[] = $row;
}