所以我有这个数组data
,我想编码有点像[lojas, raparacoes, valor],[nome_1, count_1, val_1],[nome_2, count_2, val_2], etc, etc...
lojas
,reparacoes
就像valor
标题
nome_*
来自$row['nome']
count_*
来自intval($row['COUNT( DISTINCT id_reparacao )'])
val_*
来自intval($row2['SUM(valor)'])
$data = array(array('Lojas'), array('Reparacoes'), array('Valor'));
$qry=mysql_query ('SELECT COUNT( DISTINCT id_reparacao ) , lojas.nome, lojas.id
FROM reparacoes
INNER JOIN lojas ON lojas.id = id_loja
GROUP BY lojas.id ');
while($row = mysql_fetch_array($qry))
{
$qry2=mysql_query ('SELECT SUM(valor) FROM re_servicos where id_reparacao=(select id_reparacao from reparacoes where id_loja='.$row['id'].' and estado="Fechada")');
while($row2 = mysql_fetch_array($qry2))
{
$data=[$row['nome'],intval($row['COUNT( DISTINCT id_reparacao )']), intval($row2['SUM(valor)'])];
}
}
但是,使用此代码,我没有在数组中获得所需的输出,我想问题是我填充它的方式,但我不知道如何正确填充它,所以它得到了我在第一段中发布的输出。
PS:我不知道它是否重要但为了更好地理解,我需要这个数组来构建一个谷歌条形图