function supplypoint($salesDate)
{
$sql="SELECT DISTINCT(request_id),pos_no
FROM outward
WHERE outward_date = '$salesDate'";
$query = $this->db->query($sql);
if ($query->num_rows>0)
{
foreach($query->result() as $row)
{
$request_id = $row->request_id;
echo "request_id:".$request_id;
$pos_no = $row->pos_no;
$sql1="SELECT shoppe_id FROM atm_store
WHERE pos_id = '$pos_no'";
$query1 = $this->db->query($sql1);
if($query1->num_rows>0)
{
$sql2="SELECT A.`request_id`, A.`stock_id` , A.`pos_no` ,
B.amount, sum(A.`outward` * A.`price` ) AS total, A.`outward_date`
FROM `outward` A
INNER JOIN atm_franchisees B
INNER JOIN atm_store C
ON B.user_id = C.user_id AND A.pos_no = C.pos_id
WHERE A.`outward_date`='$salesDate'
AND A.`request_id`='$request_id'
GROUP BY A.`request_id`";
}
else
{
$sql2="SELECT A.`request_id`, A.`stock_id` , A.`pos_no` ,
B.amount, sum(A.`outward` * A.`price` ) AS total, A.`outward_date`
FROM `outward` A
INNER JOIN atm_franchisees B
INNER JOIN atm_super_shoppe C ON B.user_id = C.user_id AND A.pos_no = C.pos_id
WHERE A.`outward_date`='$salesDate'
AND A.`request_id`='$request_id'
GROUP BY A.`request_id`";
}
}
$query2 = $this->db->query($sql2);
return $query2;
}
}
его возвращает только первый ряд?Можете ли вы найти проблему