1 回答
TA贡献1876条经验 获得超5个赞
您需要更干净地编写代码。您将所有查询和结果命名为类似的覆盖。
我试图更简洁地编写您的查询,以便您了解这个想法。我无法测试,因为我没有数据库,但这应该足以让你继续前进。
$query_salespartners = "SELECT sno FROM salespartners WHERE holiday_partner_sno = '$sno'";
$res_salespartners = $conn->query($query_salespartners);
if ($res_salespartners->num_rows) {
while($row = $res->fetch_assoc()){
$val = $row['sno'];
echo "$val "; //here only the first value is getting printed, suppose there are four sales partners under him, 6001,6002,6003,6004, now on execution, it prints only 6001, if there is no data to show it simply exits *all* the loops.
$query_sales= "SELECT * FROM agent_form_data
WHERE sales_partner_name ='".$val."' and formstatus = 'pending'";//on the other hand, if I remove the SQL part, all the ids under this holiday partner are getting printed, which proves that the array has it but SQL for some reason isn't checking all of the members of the array
$res_sales = $conn->query($query_sales);
if($res_sales->num_rows){
echo"Hi!";
while($row_sales = $res_sales->fetch_assoc()){
echo $row_sales["ref_num"];
$datesent =date_create($row_sales["datesent"]);
$datesent =date_format($datesent,"d-M-Y");
echo "<tr>
<td>GHRN".(5000+(int)$row_sales["ref_num"])."</td>
<td>".$row_sales["cust_firstname"]." ".$row_sales["cust_lastname"]."</td>
<td>".$row_sales["holi_dest"]."</td>
<td>".$row_sales["date_of_travel"]."</td>
<td>".$row_sales["return_date_of_travel"]."</td>
<td>".$row_sales["duration"]."</td>
<td>".$datesent."</td>
</tr>";
}
}
}
}
- 1 回答
- 0 关注
- 120 浏览
添加回答
举报