0
They asked me to add in my system a chart to compare 47 services and I opted for the highchart, however, in addition to the graph not working is with more than 5,000 lines of code, I need to reduce this urgent but as I do not master the language I have no idea how to do this.
The idea of the graph is very simple, it only takes the amount of records of each of the 47 services per month, IE, I made 47 selects 12 times.
This is the famous graphic:
/*-------------------------------------Janeiro ---------------------------------*/
require_once("strcon.php");
$totaSAJ = 0;
$totaSBJ = 0;
$totaSCJ = 0;
$totaSDJ = 0;
$totaSEJ = 0;
$totaSFJ = 0;
$totaSGJ = 0;
$totaSHJ = 0;
$totaSIJ = 0;
$totaSJJ = 0;
$totaSKJ = 0;
$totaSLJ = 0;
$totaSMJ = 0;
$totaSNJ = 0;
$totaSOJ = 0;
$totaSPJ = 0;
$totaSQJ = 0;
$totaSRJ = 0;
$totaSSJ = 0;
$totaSTJ = 0;
$totaSUJ = 0;
$totaSVJ = 0;
$totaSXJ = 0;
$totaSZJ = 0;
$totaSAAJ = 0;
$totaSABJ = 0;
$totaSACJ = 0;
$totaSADJ = 0;
$totaSAEJ = 0;
$totaSAFJ = 0;
$totaSAGJ = 0;
$totaSAHJ = 0;
$totaSAIJ = 0;
$totaSAJJ = 0;
$totaSAKJ = 0;
$totaSALJ = 0;
$totaSAMJ = 0;
$totaSANJ = 0;
$totaSAOJ = 0;
$totaSAPJ = 0;
$totaSAQJ = 0;
$totaSARJ = 0;
$totaSASJ = 0;
$totaSATJ = 0;
$totaSAUJ = 0;
$SAJ = "SELECT COUNT(ID) AS SAJan FROM pedidos WHERE SERVICO = 'Quadri Hélix' and MES = 'JAN' and ANO = '2018'";
$SBJ = "SELECT COUNT(ID) AS SBJan FROM pedidos WHERE SERVICO = 'Quadri Hélix com grade' and MES = 'JAN' and ANO = '2018'";
$SCJ = "SELECT COUNT(ID) AS SCJan FROM pedidos WHERE SERVICO = 'Quadri Hélix com batente' and MES = 'JAN' and ANO = '2018'";
$SDJ = "SELECT COUNT(ID) AS SDJan FROM pedidos WHERE SERVICO = 'Botão de Nance' and MES = 'JAN' and ANO = '2018'";
$SEJ = "SELECT COUNT(ID) AS SEJan FROM pedidos WHERE SERVICO = 'Botão Barra' and MES = 'JAN' and ANO = '2018'";
$SFJ = "SELECT COUNT(ID) AS SFJan FROM pedidos WHERE SERVICO = 'Barra Transplatina' and MES = 'JAN' and ANO = '2018'";
$SGJ = "SELECT COUNT(ID) AS SGJan FROM pedidos WHERE SERVICO = 'Barra Transplatina com grade' and MES = 'JAN' and ANO = '2018'";
$SHJ = "SELECT COUNT(ID) AS SHJan FROM pedidos WHERE SERVICO = 'Arco Lingual' and MES = 'JAN' and ANO = '2018'";
$SIJ = "SELECT COUNT(ID) AS SIJan FROM pedidos WHERE SERVICO = 'Mantedor de espaço (Alça Banda)' and MES = 'JAN' and ANO = '2018'";
$SJJ = "SELECT COUNT(ID) AS SJJan FROM pedidos WHERE SERVICO = 'Contenção Fixa Higiência' and MES = 'JAN' and ANO = '2018'";
$SKJ = "SELECT COUNT(ID) AS SKJan FROM pedidos WHERE SERVICO = 'Contenção Fixa V Bend' and MES = 'JAN' and ANO = '2018'";
$SLJ = "SELECT COUNT(ID) AS SLJan FROM pedidos WHERE SERVICO = 'Disjuntor de Mc Namara' and MES = 'JAN' and ANO = '2018'";
$SMJ = "SELECT COUNT(ID) AS SMJan FROM pedidos WHERE SERVICO = 'Disjuntor Mc Namara com grade' and MES = 'JAN' and ANO = '2018'";
$SNJ = "SELECT COUNT(ID) AS SNJan FROM pedidos WHERE SERVICO = 'Disjuntor Mc Namara modificado' and MES = 'JAN' and ANO = '2018'";
$SOJ = "SELECT COUNT(ID) AS SOJan FROM pedidos WHERE SERVICO = 'Disjuntor de Haas' and MES = 'JAN' and ANO = '2018'";
$SPJ = "SELECT COUNT(ID) AS SPJan FROM pedidos WHERE SERVICO = 'Disjuntor de Hirax' and MES = 'JAN' and ANO = '2018'";
$SQJ = "SELECT COUNT(ID) AS SQJan FROM pedidos WHERE SERVICO = 'Grade Lingual ou Palatina' and MES = 'JAN' and ANO = '2018'";
$SRJ = "SELECT COUNT(ID) AS SRJan FROM pedidos WHERE SERVICO = 'Platô' and MES = 'JAN' and ANO = '2018'";
$SSJ = "SELECT COUNT(ID) AS SSJan FROM pedidos WHERE SERVICO = 'Contenção com arco de Hawley' and MES = 'JAN' and ANO = '2018'";
$STJ = "SELECT COUNT(ID) AS STJan FROM pedidos WHERE SERVICO = 'Contenção com arco de Hawley continuo' and MES = 'JAN' and ANO = '2018'";
$SUJ = "SELECT COUNT(ID) AS SUJan FROM pedidos WHERE SERVICO = 'Contenção com arco estático' and MES = 'JAN' and ANO = '2018'";
$SVJ = "SELECT COUNT(ID) AS SVJan FROM pedidos WHERE SERVICO = 'Ap. de Hawley com Expansor' and MES = 'JAN' and ANO = '2018'";
$SXJ = "SELECT COUNT(ID) AS SXJan FROM pedidos WHERE SERVICO = 'Ap. de Hawley Encapsulado com Expansor e Aleta' and MES = 'JAN' and ANO = '2018'";
$SZJ = "SELECT COUNT(ID) AS SZJan FROM pedidos WHERE SERVICO = 'Ap. de Hawley Encapsulado com Expansor e Grade' and MES = 'JAN' and ANO = '2018'";
$SAAJ = "SELECT COUNT(ID) AS SAAJan FROM pedidos WHERE SERVICO = 'Ap. de Hawley com grade' and MES = 'JAN' and ANO = '2018'";
$SABJ = "SELECT COUNT(ID) AS SABJan FROM pedidos WHERE SERVICO = 'Ap. de Hawley com Grade e Expansor' and MES = 'JAN' and ANO = '2018'";
$SACJ = "SELECT COUNT(ID) AS SACJan FROM pedidos WHERE SERVICO = 'Ap. de Hawley com Reeducador para Língua' and MES = 'JAN' and ANO = '2018'";
$SADJ = "SELECT COUNT(ID) AS SADJan FROM pedidos WHERE SERVICO = 'Ap. de Hawley com Expansor e molas' and MES = 'JAN' and ANO = '2018'";
$AEJ = "SELECT COUNT(ID) AS SAEJan FROM pedidos WHERE SERVICO = 'Ap. de Hawley com Batente' and MES = 'JAN' and ANO = '2018'";
$SAFJ = "SELECT COUNT(ID) AS SAFJan FROM pedidos WHERE SERVICO = 'Ap. de Hawley com Batente e Expansor' and MES = 'JAN' and ANO = '2018'";
$SAGJ = "SELECT COUNT(ID) AS SAGJan FROM pedidos WHERE SERVICO = 'Ap. de Hawley com Expansor e Trava (Central ou Aleta)' and MES = 'JAN' and ANO = '2018'";
$SAHJ = "SELECT COUNT(ID) AS SAHJan FROM pedidos WHERE SERVICO = 'Ap. de Thurow' and MES = 'JAN' and ANO = '2018'";
$SAIJ = "SELECT COUNT(ID) AS SAIJan FROM pedidos WHERE SERVICO = 'Ap. de Thurow com Expansor' and MES = 'JAN' and ANO = '2018'";
$SAJJ = "SELECT COUNT(ID) AS SAJJan FROM pedidos WHERE SERVICO = 'Ap. de Bruxismo (Mio Relaxante)' and MES = 'JAN' and ANO = '2018'";
$SAKJ = "SELECT COUNT(ID) AS SAKJan FROM pedidos WHERE SERVICO = 'Placa de Michigan' and MES = 'JAN' and ANO = '2018'";
$SALJ = "SELECT COUNT(ID) AS SALJan FROM pedidos WHERE SERVICO = 'Ap. de Acetato' and MES = 'JAN' and ANO = '2018'";
$SAMJ = "SELECT COUNT(ID) AS SAMJan FROM pedidos WHERE SERVICO = 'Placa de Clareamento (par)' and MES = 'JAN' and ANO = '2018'";
$SANJ = "SELECT COUNT(ID) AS SANJan FROM pedidos WHERE SERVICO = 'Dentes de Estoque (unidade)' and MES = 'JAN' and ANO = '2018'";
$SAOJ = "SELECT COUNT(ID) AS SAOJan FROM pedidos WHERE SERVICO = 'Monobloco' and MES = 'JAN' and ANO = '2018'";
$SAPJ = "SELECT COUNT(ID) AS SAPJan FROM pedidos WHERE SERVICO = 'Planas' and MES = 'JAN' and ANO = '2018'";
$SAQJ = "SELECT COUNT(ID) AS SAQJan FROM pedidos WHERE SERVICO = 'Bimbler' and MES = 'JAN' and ANO = '2018'";
$SARJ = "SELECT COUNT(ID) AS SARJan FROM pedidos WHERE SERVICO = 'Bíator' and MES = 'JAN' and ANO = '2018'";
$SASJ = "SELECT COUNT(ID) AS SASJan FROM pedidos WHERE SERVICO = 'Klammt' and MES = 'JAN' and ANO = '2018'";
$SATJ = "SELECT COUNT(ID) AS SATJan FROM pedidos WHERE SERVICO = 'Equilibradora / SNs' and MES = 'JAN' and ANO = '2018'";
$SAUJ = "SELECT COUNT(ID) AS SAUJan FROM pedidos WHERE SERVICO = 'Frankel' and MES = 'JAN' and ANO = '2018'";
$SAVJ = "SELECT COUNT(ID) AS SAVJan FROM pedidos WHERE SERVICO = 'Ronco e Apnéia' and MES = 'JAN' and ANO = '2018'";
$consultasaj = mysqli_query($SAJ);
$consultasbj = mysqli_query($SBJ);
$consultascj = mysqli_query($SCJ);
$consultasdj = mysqli_query($SDJ);
$consultasej = mysqli_query($SEJ);
$consultasfj = mysqli_query($SFJ);
$consultasgj = mysqli_query($SGJ);
$consultashj = mysqli_query($SHJ);
$consultasij = mysqli_query($SIJ);
$consultasjj = mysqli_query($SJJ);
$consultaskj = mysqli_query($SKJ);
$consultaslj = mysqli_query($SLJ);
$consultasmj = mysqli_query($SMJ);
$consultasnj = mysqli_query($SNJ);
$consultasoj = mysqli_query($SOJ);
$consultaspj = mysqli_query($SPJ);
$consultasqj = mysqli_query($SQJ);
$consultasrj = mysqli_query($SRJ);
$consultassj = mysqli_query($SSJ);
$consultastj = mysqli_query($STJ);
$consultasuj = mysqli_query($SUJ);
$consultasvj = mysqli_query($SVJ);
$consultasxj = mysqli_query($SXJ);
$consultaszj = mysqli_query($SZJ);
$consultasaaj = mysqli_query($SAAJ);
$consultasabj = mysqli_query($SABJ);
$consultasacj = mysqli_query($SACJ);
$consultasadj = mysqli_query($SADJ);
$consultasaej = mysqli_query($SAEJ);
$consultasafj = mysqli_query($SAFJ);
$consultasagj = mysqli_query($SAGJ);
$consultasahj = mysqli_query($SAHJ);
$consultasaij = mysqli_query($SAIJ);
$consultasajj = mysqli_query($SAJJ);
$consultasakj = mysqli_query($SAKJ);
$consultasalj = mysqli_query($SALJ);
$consultasamj = mysqli_query($SAMJ);
$consultasanj = mysqli_query($SANJ);
$consultasaoj = mysqli_query($SAOJ);
$consultasapj = mysqli_query($SAPJ);
$consultasaqj = mysqli_query($SAQJ);
$consultasarj = mysqli_query($SARJ);
$consultasasj = mysqli_query($SASJ);
$consultasatj = mysqli_query($SATJ);
$consultasauj = mysqli_query($SAUJ);
$consultasavj = mysqli_query($SAVJ);
if ($consultasaj = mysqli_query($strcon, $SAJ)) {
if ($rowsaj = mysqli_fetch_assoc($consultasaj)) {
$totaSAJ = $rowsaj['SAJan']; //Seta o total
}
mysqli_free_result($consultasaj);
} else {
}
if ($consultasbj = mysqli_query($strcon, $SBJ)) {
if ($rowsbj = mysqli_fetch_assoc($consultasbj)) {
$totaSBJ = $rowsbj['SBJan']; //Seta o total
}
mysqli_free_result($consultasbj);
} else {
}
if ($consultascj = mysqli_query($strcon, $SCJ)) {
if ($rowscj = mysqli_fetch_assoc($consultascj)) {
$totaSCJ = $rowsbj['SCJan']; //Seta o total
}
mysqli_free_result($consultascj);
} else {
}
if ($consultasdj = mysqli_query($strcon, $SDJ)) {
if ($rowsdj = mysqli_fetch_assoc($consultasdj)) {
$totaSDJ = $rowsbj['SDJan']; //Seta o total
}
mysqli_free_result($consultasdj);
} else {
}
if ($consultasej = mysqli_query($strcon, $SEJ)) {
if ($rowsej = mysqli_fetch_assoc($consultasej)) {
$totaSEJ = $rowsbj['SEJan']; //Seta o total
}
mysqli_free_result($consultasej);
} else {
}
if ($consultasfj = mysqli_query($strcon, $SFJ)) {
if ($rowsfj = mysqli_fetch_assoc($consultasfj)) {
$totaSFJ = $rowsfj['SFJan']; //Seta o total
}
mysqli_free_result($consultasfj);
} else {
}
if ($consultasgj = mysqli_query($strcon, $SGJ)) {
if ($rowsgj = mysqli_fetch_assoc($consultasgj)) {
$totaSGJ = $rowsgj['SGJan']; //Seta o total
}
mysqli_free_result($consultasgj);
} else {
}
if ($consultashj = mysqli_query($strcon, $SHJ)) {
if ($rowshj = mysqli_fetch_assoc($consultashj)) {
$totaSHJ = $rowshj['SHJan']; //Seta o total
}
mysqli_free_result($consultashj);
} else {
}
if ($consultasij = mysqli_query($strcon, $SIJ)) {
if ($rowsij = mysqli_fetch_assoc($consultasij)) {
$totaSIJ = $rowsij['SIJan']; //Seta o total
}
mysqli_free_result($consultasij);
} else {
}
if ($consultasjj = mysqli_query($strcon, $SJJ)) {
if ($rowsjj = mysqli_fetch_assoc($consultasjj)) {
$totaSJJ = $rowsjj['SJJan']; //Seta o total
}
mysqli_free_result($consultasjj);
} else {
}
if ($consultaskj = mysqli_query($strcon, $SKJ)) {
if ($rowskj = mysqli_fetch_assoc($consultaskj)) {
$totaSKJ = $rowskj['SKJan']; //Seta o total
}
mysqli_free_result($consultaskj);
} else {
}
if ($consultaslj = mysqli_query($strcon, $SLJ)) {
if ($rowslj = mysqli_fetch_assoc($consultaslj)) {
$totaSLJ = $rowslj['SLJan']; //Seta o total
}
mysqli_free_result($consultaslj);
} else {
}
if ($consultasmj = mysqli_query($strcon, $SCMJ)) {
if ($rowsmj = mysqli_fetch_assoc($consultasmj)) {
$totaSMJ = $rowsmj['SMJan']; //Seta o total
}
mysqli_free_result($consultasmj);
} else {
}
if ($consultasnj = mysqli_query($strcon, $SNJ)) {
if ($rowsnj = mysqli_fetch_assoc($consultasnj)) {
$totaSNJ = $rowsnj['SNJan']; //Seta o total
}
mysqli_free_result($consultasnj);
} else {
}
if ($consultasoj = mysqli_query($strcon, $SOJ)) {
if ($rowseoj = mysqli_fetch_assoc($consultasoj)) {
$totaSOJ = $rowsoj['SOJan']; //Seta o total
}
mysqli_free_result($consultasoj);
} else {
}
if ($consultaspj = mysqli_query($strcon, $SPJ)) {
if ($rowspj = mysqli_fetch_assoc($consultaspj)) {
$totaSPJ = $rowspj['SPJan']; //Seta o total
}
mysqli_free_result($consultaspj);
} else {
}
if ($consultasqj = mysqli_query($strcon, $SQJ)) {
if ($rowsqj = mysqli_fetch_assoc($consultasqj)) {
$totaSQJ = $rowsqj['SQJan']; //Seta o total
}
mysqli_free_result($consultasqj);
} else {
}
if ($consultasrj = mysqli_query($strcon, $SRJ)) {
if ($rowsrj = mysqli_fetch_assoc($consultasrj)) {
$totaSRJ = $rowsrj['SRJan']; //Seta o total
}
mysqli_free_result($consultasrj);
} else {
}
if ($consultassj = mysqli_query($strcon, $SSJ)) {
if ($rowssj = mysqli_fetch_assoc($consultassj)) {
$totaSSJ = $rowssj['SSJan']; //Seta o total
}
mysqli_free_result($consultassj);
} else {
}
if ($consultastj = mysqli_query($strcon, $STJ)) {
if ($rowstj = mysqli_fetch_assoc($consultastj)) {
$totaSTJ = $rowstj['STJan']; //Seta o total
}
mysqli_free_result($consultastj);
} else {
}
if ($consultasuj = mysqli_query($strcon, $SUJ)) {
if ($rowsuj = mysqli_fetch_assoc($consultasuj)) {
$totaSUJ = $rowsuj['SUJan']; //Seta o total
}
mysqli_free_result($consultasuj);
} else {
}
if ($consultasvj = mysqli_query($strcon, $SVJ)) {
if ($rowsvj = mysqli_fetch_assoc($consultasvj)) {
$totaSVJ = $rowsvj['SVJan']; //Seta o total
}
mysqli_free_result($consultasvj);
} else {
}
if ($consultasxj = mysqli_query($strcon, $SXJ)) {
if ($rowsxj = mysqli_fetch_assoc($consultasxj)) {
$totaSXJ = $rowsxj['SXJan']; //Seta o total
}
mysqli_free_result($consultasxj);
} else {
}
if ($consultaszj = mysqli_query($strcon, $SZJ)) {
if ($rowszj = mysqli_fetch_assoc($consultaszj)) {
$totaSZJ = $rowszj['SZJan']; //Seta o total
}
mysqli_free_result($consultaszj);
} else {
}
if ($consultasaaj = mysqli_query($strcon, $SAAJ)) {
if ($rowsaaj = mysqli_fetch_assoc($consultasaaj)) {
$totaSAAJ = $rowsaaj['SAAJan']; //Seta o total
}
mysqli_free_result($consultasaaj);
} else {
}
if ($consultasabj = mysqli_query($strcon, $SABJ)) {
if ($rowsabj = mysqli_fetch_assoc($consultasabj)) {
$totaSABJ = $rowsabj['SABJan']; //Seta o total
}
mysqli_free_result($consultasabj);
} else {
}
if ($consultasacj = mysqli_query($strcon, $SACJ)) {
if ($rowsacj = mysqli_fetch_assoc($consultasacj)) {
$totaSACJ = $rowsacj['SACJan']; //Seta o total
}
mysqli_free_result($consultasacj);
} else {
}
if ($consultasadj = mysqli_query($strcon, $SADJ)) {
if ($rowsadj = mysqli_fetch_assoc($consultasadj)) {
$totaSADJ = $rowsadj['SADJan']; //Seta o total
}
mysqli_free_result($consultasadj);
} else {
}
if ($consultasaej = mysqli_query($strcon, $SAEJ)) {
if ($rowsaej = mysqli_fetch_assoc($consultasaej)) {
$totaSAEJ = $rowsaej['SAEJan']; //Seta o total
}
mysqli_free_result($consultasaej);
} else {
}
if ($consultasafj = mysqli_query($strcon, $SAFJ)) {
if ($rowsafj = mysqli_fetch_assoc($consultasafj)) {
$totaSAFJ = $rowsafj['SAFJan']; //Seta o total
}
mysqli_free_result($consultasafj);
} else {
}
if ($consultasagj = mysqli_query($strcon, $SAGJ)) {
if ($rowsagj = mysqli_fetch_assoc($consultasagj)) {
$totaSAGJ = $rowsagj['SAGJan']; //Seta o total
}
mysqli_free_result($consultasagj);
} else {
}
if ($consultasahj = mysqli_query($strcon, $SAHJ)) {
if ($rowsahj = mysqli_fetch_assoc($consultasahj)) {
$totaSAHJ = $rowsahj['SAHJan']; //Seta o total
}
mysqli_free_result($consultasahj);
} else {
}
if ($consultasaij = mysqli_query($strcon, $SAIJ)) {
if ($rowsaij = mysqli_fetch_assoc($consultasaij)) {
$totaSAIJ = $rowsaij['SAIJan']; //Seta o total
}
mysqli_free_result($consultasaij);
} else {
}
if ($consultasajj = mysqli_query($strcon, $SAJJ)) {
if ($rowsajj = mysqli_fetch_assoc($consultasajj)) {
$totaSAJJ = $rowsajj['SAJJan']; //Seta o total
}
mysqli_free_result($consultasajj);
} else {
}
if ($consultaskj = mysqli_query($strcon, $SAKJ)) {
if ($rowsakj = mysqli_fetch_assoc($consultasakj)) {
$totaSAKJ = $rowsakj['SAKJan']; //Seta o total
}
mysqli_free_result($consultasakj);
} else {
}
if ($consultasalj = mysqli_query($strcon, $SALJ)) {
if ($rowsalj = mysqli_fetch_assoc($consultasalj)) {
$totaSALJ = $rowsalj['SALJan']; //Seta o total
}
mysqli_free_result($consultasalj);
} else {
}
if ($consultasamj = mysqli_query($strcon, $SAMJ)) {
if ($rowsamj = mysqli_fetch_assoc($consultasamj)) {
$totaSAMJ = $rowsamj['SAMJan']; //Seta o total
}
mysqli_free_result($consultasamj);
} else {
}
if ($consultasanj = mysqli_query($strcon, $SANJ)) {
if ($rowsanj = mysqli_fetch_assoc($consultasanj)) {
$totaSANJ = $rowsanj['SANJan']; //Seta o total
}
mysqli_free_result($consultasanj);
} else {
}
if ($consultasaoj = mysqli_query($strcon, $SAOJ)) {
if ($rowsaoj = mysqli_fetch_assoc($consultasaoj)) {
$totaSAOJ = $rowsaoj['SAOJan']; //Seta o total
}
mysqli_free_result($consultasaoj);
} else {
}
if ($consultasapj = mysqli_query($strcon, $SAPJ)) {
if ($rowsapj = mysqli_fetch_assoc($consultasapj)) {
$totaSAPJ = $rowsapj['SAPJan']; //Seta o total
}
mysqli_free_result($consultasapj);
} else {
}
if ($consultasapj = mysqli_query($strcon, $SAPJ)) {
if ($rowsapj = mysqli_fetch_assoc($consultasapj)) {
$totaSAJ = $rowsaj['SAJan']; //Seta o total
}
mysqli_free_result($consultasapj);
} else {
}
if ($consultasaqj = mysqli_query($strcon, $SAQJ)) {
if ($rowsaqj = mysqli_fetch_assoc($consultasaqj)) {
$totaSAQJ = $rowsaqj['SAQJan']; //Seta o total
}
mysqli_free_result($consultasaqj);
} else {
}
if ($consultasarj = mysqli_query($strcon, $SARJ)) {
if ($rowsarj = mysqli_fetch_assoc($consultasarj)) {
$totaSARJ = $rowsarj['SARJan']; //Seta o total
}
mysqli_free_result($consultasarj);
} else {
}
if ($consultasasj = mysqli_query($strcon, $SASJ)) {
if ($rowsasj = mysqli_fetch_assoc($consultasasj)) {
$totaSASJ = $rowsasj['SASJan']; //Seta o total
}
mysqli_free_result($consultasasj);
} else {
}
if ($consultasatj = mysqli_query($strcon, $SATJ)) {
if ($rowsatj = mysqli_fetch_assoc($consultasatj)) {
$totaSATJ = $rowsatj['SATJan']; //Seta o total
}
mysqli_free_result($consultasatj);
} else {
}
if ($consultasavj = mysqli_query($strcon, $SAVJ)) {
if ($rowsavj = mysqli_fetch_assoc($consultasavj)) {
$totaSAVJ = $rowsavj['SAVJan']; //Seta o total
}
mysqli_free_result($consultasavj);
} else {
}
?>
<script type="text/javascript">
Highcharts.chart('container', {
title: {
text: 'Indicador anual de serviços'
},
subtitle: {
text: ''
},
xAxis: [{
categories: ['Jan', 'Fev', 'Mar', 'Abr', 'Mai', 'Jun',
'Jul', 'Ago', 'Set', 'Out', 'Nov', 'Dez'],
crosshair: true
}],
yAxis: {
title: {
text: ''
}
},
legend: {
layout: 'vertical',
align: 'right',
verticalAlign: 'middle'
},
series: [{
name: 'Quadri Hélix',
data: [<?php echo $rowsaj['SAJan'];?>, <?php echo $rowsaf['SAFev'];?>,<?php echo $rowsamar['SAMar'];?>, <?php echo $rowsaabr['SAAbr'];?>, <?php echo $rowsamai['SAMai'];?>, <?php echo $rowsajun['SAJun'];?>, <?php echo $rowsajul['SAJul'];?>, <?php echo $rowsaago['SAAgo'];?>, <?php echo $rowsaset['SASet'];?>, <?php echo $rowsaout['SAOut'];?>, <?php echo $rowsanov['SANov'];?>, <?php echo $rowsadez['SADez'];?>]
}, {
name: 'Quadri Hélix com grade',
data: [<?php echo $rowsbj['SBJan'];?>,<?php echo $rowsbf['SBFev'];?>, <?php echo $rowsbmar['SBMar'];?>, <?php echo $rowsbabr['SBAbr'];?>, <?php echo $rowsbmai['SBMai'];?>, <?php echo $rowsbjun['SBJun'];?>,<?php echo $rowsbjul['SBJul'];?>, <?php echo $rowsbago['SBAgo'];?>, <?php echo $rowsbset['SBSet'];?>, <?php echo $rowsbout['SBOut'];?>, <?php echo $rowsbnov['SBNov'];?>, <?php echo $rowsbdez['SBDez'];?>]
}, {
responsive: {
rules: [{
condition: {
tickInterval: 1,
},
chartOptions: {
legend: {
layout: 'horizontal',
align: 'center',
verticalAlign: 'bottom'
}
}
}]
}
});
</script>
I couldn’t put the whole code here but there’s no need, the php part just repeats the same thing I did for January every month. The jscript part only repeats the same thing I did on both services for all 47 services.
Here are images of the famous: Does anyone know how to optimize, reduce the size of this business?
Why not just make an sql? Ex:
SELECT COUNT(ID) AS SAVJan, SERVICO FROM pedidos WHERE MES = 'JAN' and ANO = '2018' GROUP BY SERVICO
? It already reduces half the code... And vc will have an array with Qtde and service name, then just put in Chart.– Max Rogério
No, I don’t understand. Will this select return me the amount of records of all services? And how I put it that way on the highchart if I put each select being a value in the month?
– Mariana Bayonetta
series: [{
 name: 'Quadri Hélix',
 data: [<?php echo $rowsaj['SAJan'];?>, <?php echo $rowsaf['SAFev'];?>,<?php echo $rowsamar['SAMar'];?>, <?php echo $rowsaabr['SAAbr'];?>, <?php echo $rowsamai['SAMai'];?>, <?php echo $rowsajun['SAJun'];?>, <?php echo $rowsajul['SAJul'];?>, <?php echo $rowsaago['SAAgo'];?>, <?php echo $rowsaset['SASet'];?>, <?php echo $rowsaout['SAOut'];?>, <?php echo $rowsanov['SANov'];?>, <?php echo $rowsadez['SADez'];?>]
--> Here he will take the first service of each month to assemble the line of the first service. I need all select– Mariana Bayonetta
I didn’t understand in your code where you search the months, and in the bank query you have only the condition
WHERE MES = 'JAN'
– Max Rogério
For each month I made 47 selects
SELECT COUNT(ID) AS SAMar FROM pedidos WHERE SERVICO = 'Serviço A' and MES = 'MAR' and ANO = '2018'"
Then I take the amount of records presented in each select, put it on a Row and put Row on the highchart.– Mariana Bayonetta