Answer the question
In order to leave comments, you need to log in
Loop within a loop, how to implement?
Two requests
/*Выборка дат по закупкам*/
$procurement = mysql_query ("SELECT data_start_god
FROM goods
WHERE id_com_god='{$company['inde_com']}' GROUP BY data_start_god ORDER BY `data_start_god` ASC LIMIT 7",$db);
while ($rowk = mysql_fetch_array($procurement))
echo "'{$rowk['data_start_god']}',";
/*Подсчет cуммы товара*/
$product = mysql_query ("SELECT SUM(start_col_god)
FROM goods
WHERE id_com_god='{$company['inde_com']}' AND data_start_god='{$rowk['data_start_god']}' ORDER BY `start_col_god` ASC LIMIT 7",$db);
while ($pro = mysql_fetch_array($product))
echo "'$pro[0]',";
Answer the question
In order to leave comments, you need to log in
@WaRstim :
"you need two separate requests, so they will be in different places in javascript"
/*Выборка дат по закупкам*/
$procurement = mysql_query ("SELECT data_start_god
FROM goods
WHERE id_com_god='{$company['inde_com']}' GROUP BY data_start_god ORDER BY `data_start_god` ASC LIMIT 7",$db);
while ($rowk = mysql_fetch_array($procurement))
echo "'{$rowk['data_start_god']}',";
foreach($rowk as <b>$itm</b>) {
/*Подсчет cуммы товара*/
$product = mysql_query ("SELECT SUM(start_col_god)
FROM goods
WHERE id_com_god='{$company['inde_com']}' AND data_start_god='{<b>$itm</b>['data_start_god']}' ORDER BY `start_col_god` ASC LIMIT 7",$db);
while ($pro = mysql_fetch_array($product))
echo "'$pro[0]',";
}
$procurement = mysql_query ("SELECT data_start_god<b>, sum(start_col_god) as sum_col_god </b>
FROM goods
WHERE id_com_god='{$company['inde_com']}' GROUP BY data_start_god ORDER BY `data_start_god` ASC LIMIT 7",$db);
while ($rowk = mysql_fetch_array($procurement))
echo "'{$rowk['data_start_god']}',";
Perhaps I did not understand the task, but what prevents it from being done in one request?
select ..., SUM(number of products)
where ...
group by [company_id,] date
order by date desc
limit 7?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question