以数组格式获取数据:
$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");
答案 0 :(得分:1)
获取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);
答案 1 :(得分:1)
如果“ ABC”,“ XYZ”,“ OPQ”是相同的字段[designation],则可以将$ designation转换为数组。
$query = "SELECT * FROM designation_master";
$result = mysqli_query($mysqli, $query);
$designation = array();
while ($row = mysqli_fetch_array($result))
{
$designation[] = $row["designation"];
}