我无法从while循环获取规则点数据。请帮助我...... :(
以下是我的代码
<?php
$employee_query = $dbcon->query("SELECT * FROM employee ORDER BY name ASC");
while($employee_array = $employee_query->fetch_array()):
$employee_ids = $employee_array['id'];
$department_ids = $employee_array['department_id'];
$department_query = $dbcon->query("SELECT * FROM department WHERE id='$department_ids'");
$department_array = $department_query->fetch_assoc();
?>
<tr>
<td> <small> <strong> <?= $employee_array['name']; ?> </strong> </small> </td>
<td> <small> <strong> <?= $department_array['department']; ?> </strong> </small> </td>
<td> <small> <strong> <?= $y; ?> </strong> </small> </td>
<td> <small> <strong> <?= $m; ?> </strong> </small> </td>
<td> <small> <strong> <?= $w; ?> Week </strong> </small> </td>
<td> <small> <strong> <?= $pd['week_range']; ?> </strong> </small> </td>
<td>
<?php
$pm_query = $dbcon->query("SELECT * FROM performance_management WHERE performance_id='$pid' AND department_id='$department_ids' AND employee_id='$employee_ids'");
while($pm_data = $pm_query->fetch_array()):
echo $rules_ids = $pm_data['rules_id'];
$rules_query = $dbcon->query("SELECT * FROM point WHERE rules_id='$rules_ids'");
$rules_data = $rules_query->fetch_assoc();
echo $rules_data['points'];
endwhile;
?>
</td>
</tr>
在上面的代码中,我无法获得$rules_data['points']
答案 0 :(得分:0)
fetch_assoc()
将所有row
作为associative array
返回。所以像这样访问它
echo $rules_data[0]['points'];
更新:
您的$rules_ids
值为47,30,36
,因此您需要使用IN clause
查询
"SELECT * FROM point WHERE rules_id IN (".$rules_ids.")"