以数组格式获取数据,如:

$value = array ("ABC","XYZ","OPQ");

$query = "SELECT * FROM  designation_master";
$result = mysqli_query($mysqli, $query);
while ($row = mysqli_fetch_array($result)) {
    $designation= $row["designation"];
}

需要结果:
$value = array ("ABC","XYZ","OPQ");

最佳答案

获取designation列,并将其推入语法为$array[] = $value的数组中。

$designation = [];
$query = "SELECT designation FROM  designation_master";
$result = mysqli_query($mysqli, $query);
while ($row = mysqli_fetch_array($result)) {
    $designation[] = $row["designation"];
}
print_r($designation);

关于php - 在PHP和MySQL中以数组格式获取数据,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/55951957/

10-11 23:53