Ir para conteúdo
Fórum Script Brasil

WelltBenicio

Membros
  • Total de itens

    4
  • Registro em

  • Última visita

Tudo que WelltBenicio postou

  1. WelltBenicio

    Php

    Bom baixei um novo gráfico e tentei de outra forma, só que ainda não consegui declarar a variável que vai buscar o resultado da função. <?php require_once('Connections/conn_bd.php'); ?> <?php if (!function_exists("GetSQLValueString")) { function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") { if (PHP_VERSION < 6) { $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue; } $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue); switch ($theType) { case "text": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "long": case "int": $theValue = ($theValue != "") ? intval($theValue) : "NULL"; break; case "double": $theValue = ($theValue != "") ? doubleval($theValue) : "NULL"; break; case "date": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "defined": $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue; break; } return $theValue; } } ?> <?php function subtrair ($x, $y){ return $resultado = $x - $y; } $nr1 = 10; $nr2 = 5; echo ("$resultado" . subtrair ($nr1, $nr2) . "</p>"); ?> <html> <head> <title>Gráfico Dinâmico com API Javascript do Google | DBorges TI</title> <!--DEFINE O ENCONDING DA PÁGINA - UTF-8--> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <!--CHAMA A API DO GOOGLE--> &lt;script type="text/javascript" src="https://www.google.com/jsapi"></script> <!--SCRIPT QUE IRÁ DEFINIR AS CONFIGURAÇÕES DO GRÁFICO, COMO TITULOS, TAREFAS, VALORES, ETC...--> &lt;script type="text/javascript"> google.load("visualization", "1", {packages:["corechart"]}); google.setOnLoadCallback(drawChart); function drawChart() { var data = new google.visualization.DataTable(); data.addColumn('string', 'Tarefa'); data.addColumn('number', 'Horas por Dia'); data.addRows(5); <!--TAREFA 1--> data.setValue(0, 0, 'Nextel'); data.setValue(0, 1, <?php echo $resultado['nr1, nr2']; ?>); <!--TAREFA 2--> data.setValue(1, 0, 'Informatica'); data.setValue(1, 1, 10); <!--TAREFA 3--> data.setValue(2, 0, 'Telefone'); data.setValue(2, 1, 2); <!-- DEFINE QUE A VARIÁVEL CHART ESTÁ RELACIONADA COM O GRÁFICO E ATRIBUI AO ID chart_div --> var chart = new google.visualization.PieChart(document.getElementById('chart_div')); <!-- DEFINE O TAMANHO QUE IRÁ APARECER EM TELA E O TÍTULO DO GRÁFICO--> chart.draw(data, {width: 450, height: 300, title: 'Chamados ainda não atendidos'}); } </script> </head> <body> <!--MOSTRA O GRÁFICO EM TELA--> <div id="chart_div"></div> </body> </html> Na linha onde esta escrito <?php echo $resultado['nr1, nr2']; ?>); deve conter algum erro porque ele não monta o gráfico so que se eu mudar essa valor para qualquer numero inteiro ele funciona, Ex:10, 1, 5. O meu intuito é fazer com que o resultado da função seja o valor dessa variável, que é um dos valores da barra do gráfico. Se alguém poder me ajudar agradeço desde já.
  2. WelltBenicio

    Php

    Bom tentei desta forma mas não funciona... <?php virtual('/Connections/conn_bd.php'); ?> <?php if (!function_exists("GetSQLValueString")) { function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") { if (PHP_VERSION < 6) { $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue; } $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue); switch ($theType) { case "text": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "long": case "int": $theValue = ($theValue != "") ? intval($theValue) : "NULL"; break; case "double": $theValue = ($theValue != "") ? doubleval($theValue) : "NULL"; break; case "date": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "defined": $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue; break; } return $theValue; } } mysql_select_db($database_conn_bd, $conn_bd); $query_Recordset1 = "SELECT * FROM suporte_informatica ORDER BY cod_suporte DESC"; $Recordset1 = mysql_query($query_Recordset1, $conn_bd) or die(mysql_error()); $exibir = mysql_query("SELECT * FROM suporte_informatica WHERE terminada = 0"); while ($ee=mysql_fetch_array($exibir)) { } echo $exibir; ?> <!DOCTYPE html> <html> <head> <title>Status</title> <script src="libraries/RGraph.common.core.js" ></script> <script src="libraries/RGraph.common.annotate.js" ></script> <script src="libraries/RGraph.common.context.js" ></script> <script src="libraries/RGraph.common.tooltips.js" ></script> <script src="libraries/RGraph.common.resizing.js" ></script> <script src="libraries/RGraph.bar.js" ></script> <script> var chamado = [2, 2, 2] var cahamadoinformatica =2; var chamadoramal =2; var chamadonextel =2; </script> <script> window.onload = function () { var meuGraficoIdades = new RGraph.Bar('meuCanvasGraficoIdades', chamado); meuGraficoIdades.Set('chart.background.barcolor1', 'white'); //dupla de linhas meuGraficoIdades.Set('chart.background.barcolor2', 'white'); //a outra dupla de linhas do grafico meuGraficoIdades.Set('chart.title', 'Total de chamados terminados'); //nome que fica acima do grafico meuGraficoIdades.Set('chart.title.vpos', 0.6); //altura do nome que esta acima do grafico meuGraficoIdades.Set('chart.labels', ['Informática', 'Telefone', 'Nextel']);//nome das palavras que ficam abaixo das barras meuGraficoIdades.Set('chart.tooltips', ['Chamados de informatica tem ' + cahamadoinformatica + ' chamados terminados', 'Chamados de ramal tem ' + chamadoramal + ' chamados terminados', 'Chamados nextel tem ' + chamadonextel + ' chamados terminados']); //nomes que aparecem quando o mouse esta em cima da barra meuGraficoIdades.Set('chart.text.angle', 45); meuGraficoIdades.Set('chart.gutter', 20); //tamanho do grafico image meuGraficoIdades.Set('chart.shadow', true); //sombra das barras meuGraficoIdades.Set('chart.shadow.blur', 10); //borrado da sombra da barra meuGraficoIdades.Set('chart.shadow.color', '#aaa'); //cor da sombra das barras meuGraficoIdades.Set('chart.shadow.offsety', -3); //distancia da sombra da barra na vertical meuGraficoIdades.Set('chart.colors', ['#00CED1']); //cor de fundo da barra do grafico meuGraficoIdades.Set('chart.key.position', 'gutter'); meuGraficoIdades.Set('chart.text.size', 10); //tamanho das letras da barras meuGraficoIdades.Set('chart.text.font', 'arial'); //fonte das letras meuGraficoIdades.Set('chart.text.angle', 0); //inclinando as letras abaixo da barra meuGraficoIdades.Set('chart.grouping', 'stacked'); meuGraficoIdades.Set('chart.strokecolor', 'rgba(0,0,0,0)'); //pequeno contorno das barras meuGraficoIdades.Draw(); } </script> </head> <body> <div style="width: 600px;" align="center"> <!--propriedades do texto de erro --> <canvas id="meuCanvasGraficoIdades" width="300" height="350">Este navegador não suporta este tipo de script.</canvas> <!--tamanho do grafico --> </div> </body> </html> <?php mysql_free_result($Recordset1); ?> Era pra ele exibir a quantidades de campos que estão com valor 0, só que ele exibe somente: "Resource id #5" Tem algum erro aparente?
  3. WelltBenicio

    Php

    Sou novo em php, fiz um script que conta e soma quantos campos da coluna terminada do banco de dados estão com valor 1 de três tabelas diferentes e cria um gráfico de três barras baseado nos resultados. <?php virtual('/Connections/conn_bd.php'); ?> <?php if (!function_exists("GetSQLValueString")) { function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") { if (PHP_VERSION < 6) { $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue; } $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue); switch ($theType) { case "text": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "long": case "int": $theValue = ($theValue != "") ? intval($theValue) : "NULL"; break; case "double": $theValue = ($theValue != "") ? doubleval($theValue) : "NULL"; break; case "date": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "defined": $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue; break; } return $theValue; } } mysql_select_db($database_conn_bd, $conn_bd); $query_Recordset1 = "SELECT * FROM suporte_informatica ORDER BY cod_suporte DESC"; $Recordset1 = mysql_query($query_Recordset1, $conn_bd) or die(mysql_error()); $row_Recordset1 = mysql_fetch_assoc($Recordset1); $totalRows_Recordset1 = mysql_num_rows($Recordset1); mysql_select_db($database_conn_bd, $conn_bd); $query_Recordset2 = "SELECT * FROM suporte_telefone ORDER BY codigo_usuario DESC"; $Recordset2 = mysql_query($query_Recordset2, $conn_bd) or die(mysql_error()); $row_Recordset2 = mysql_fetch_assoc($Recordset2); $totalRows_Recordset2 = mysql_num_rows($Recordset2); mysql_select_db($database_conn_bd, $conn_bd); $query_Recordset3 = "SELECT * FROM suporte_nextel ORDER BY codigo_usuario DESC"; $Recordset3 = mysql_query($query_Recordset3, $conn_bd) or die(mysql_error()); $row_Recordset3 = mysql_fetch_assoc($Recordset3); $totalRows_Recordset3 = mysql_num_rows($Recordset3); $soma = mysql_query("SELECT SUM( terminada ) as soma FROM suporte_informatica"); $array = mysql_fetch_array ($soma); $soma2 = mysql_query("SELECT SUM( terminada ) as soma2 FROM suporte_telefone"); $array2 = mysql_fetch_array ($soma2); $soma3 = mysql_query("SELECT SUM( terminada ) as soma3 FROM suporte_nextel"); $array3 = mysql_fetch_array ($soma3); ?> <!DOCTYPE html> <html> <head> <title>Status</title> <script src="libraries/RGraph.common.core.js" ></script> <script src="libraries/RGraph.common.annotate.js" ></script> <script src="libraries/RGraph.common.context.js" ></script> <script src="libraries/RGraph.common.tooltips.js" ></script> <script src="libraries/RGraph.common.resizing.js" ></script> <script src="libraries/RGraph.bar.js" ></script> <script> var chamado = [<?php echo $array['soma']; ?>, <?php echo $array2['soma2']; ?>, <?php echo $array3['soma3']; ?>] var cahamadoinformatica =<?php echo $array['soma']; ?>; var chamadoramal =<?php echo $array2['soma2']; ?>; var chamadonextel =<?php echo $array3['soma3']; ?>; </script> <script> window.onload = function () { var meuGraficoIdades = new RGraph.Bar('meuCanvasGraficoIdades', chamado); meuGraficoIdades.Set('chart.background.barcolor1', 'white'); //dupla de linhas meuGraficoIdades.Set('chart.background.barcolor2', 'white'); //a outra dupla de linhas do grafico meuGraficoIdades.Set('chart.title', 'Total de chamados terminados'); //nome que fica acima do grafico meuGraficoIdades.Set('chart.title.vpos', 0.6); //altura do nome que esta acima do grafico meuGraficoIdades.Set('chart.labels', ['Informática', 'Telefone', 'Nextel']);//nome das palavras que ficam abaixo das barras meuGraficoIdades.Set('chart.tooltips', ['Chamados de informatica tem ' + cahamadoinformatica + ' chamados terminados', 'Chamados de ramal tem ' + chamadoramal + ' chamados terminados', 'Chamados nextel tem ' + chamadonextel + ' chamados terminados']); //nomes que aparecem quando o mouse esta em cima da barra meuGraficoIdades.Set('chart.text.angle', 45); meuGraficoIdades.Set('chart.gutter', 20); //tamanho do grafico image meuGraficoIdades.Set('chart.shadow', true); //sombra das barras meuGraficoIdades.Set('chart.shadow.blur', 10); //borrado da sombra da barra meuGraficoIdades.Set('chart.shadow.color', '#aaa'); //cor da sombra das barras meuGraficoIdades.Set('chart.shadow.offsety', -3); //distancia da sombra da barra na vertical meuGraficoIdades.Set('chart.colors', ['#00CED1']); //cor de fundo da barra do grafico meuGraficoIdades.Set('chart.key.position', 'gutter'); meuGraficoIdades.Set('chart.text.size', 10); //tamanho das letras da barras meuGraficoIdades.Set('chart.text.font', 'arial'); //fonte das letras meuGraficoIdades.Set('chart.text.angle', 0); //inclinando as letras abaixo da barra meuGraficoIdades.Set('chart.grouping', 'stacked'); meuGraficoIdades.Set('chart.strokecolor', 'rgba(0,0,0,0)'); //pequeno contorno das barras meuGraficoIdades.Draw(); } </script> </head> <body> <div style="width: 600px;" align="center"> <!--propriedades do texto de erro --> <canvas id="meuCanvasGraficoIdades" width="300" height="350">Este navegador não suporta este tipo de script.</canvas> <!--tamanho do grafico --> </div> </body> </html> <?php mysql_free_result($Recordset1); mysql_free_result($Recordset2); mysql_free_result($Recordset3); ?> Alguém sabe como faço outro script para que ele conte os campos do banco de dados que estão com valor 0 e valor nulo?
  4. WelltBenicio

    Php

    Olá pessoal, eu estou com uma duvida em php, Tenho uma pagina chamada teste1.php que executa a seguinte função: <?php function subtrair ($x, $y){ return $resultado = $x - $y; } $nr1 = 10; $nr2 = 5; echo ("$resultado" . subtrair ($nr1, $nr2) . "</p>"); ?> em outra pagina chamada "chamados_abertos.php" eu declaro o valor das variareis de um gráfico em JavaScript assim: var chamado = [2, 2, 2] Alguém sabe como eu devo fazer para que o valor da variável da pagina "chamados_abertos.php" puxe o resultado da função da pagina "teste1.php" Valeu desde já agradeço.
×
×
  • Criar Novo...