21,887
社区成员
发帖
与我相关
我的任务
分享
$orderList = array();
include("connect.php")
//获取申请列表
$sql = "select * from orderform order by date DESC";
$res = $conn -> query($sql);
while($row = $res -> fetch_assoc()) { array_push($orderList, $row); }
//查询申请人姓名
foreach ($orderList as $value) {
$applicantID= $value["applicantID"];
$sql_Name = "select name from user where id = '{$applicantID}'";
$res = $conn -> query($sql_Name);
while($row = $res -> fetch_assoc()) { $applicantName = $row["name"]; }
$value["applicantName"] = "{$applicantName}";
print_r($value);
}
print_r($orderList);
$conn -> close();
$orderList[$key]['applicantName'] = "{$applicantName}";
片段修改:
// 查询申请人姓名
foreach ($orderList as $key => $value) {
$applicantID = $value['applicantID'];
$sql_Name = "select name from user where id = '{$applicantID}'";
$res = $conn -> query($sql_Name);
while($row = $res -> fetch_assoc()) { $applicantName = $row['name']; }
$orderList[$key]['applicantName'] = "{$applicantName}";
}