-
Conteúdo Similar
-
Por PeeWee
Opaa, o problema é o seguinte: preciso fazer uma busca no BD com esse código:
$buscar = $pdo->prepare("SELECT * FROM `produtos` WHERE `titulo` LIKE '%$textoBusca%'");
$buscar->execute();
$retorno = array();
$retorno['dados'] = '';
$retorno['qtd'] = $buscar->rowCount();
if($retorno['qtd'] >= 0){
while($conteudo = $buscar->fetchObject()){
$retorno['dados'] .= '<a href="#" id="'.$conteudo->id.':'.$conteudo->valor.'">'.utf8_encode($conteudo->titulo).'</a>';
}
}
O problema é que os resultados estão vindo duplicados (no BD só há 3 registros)
Não tenho idéia do que fazer, se alguem puder ajudar agradeço desde já.
-
Por Wilson Fernandes
Olá! Preciso de ajuda para começar a construir gráficos de funções quadráticas em plano cartesiano. Já procurei várias fontes, mas nenhuma explica como construir um bom gráfico.
-
Por arleyfroes
Boa Tarde,
eu tenho o seguinte código com os dados do gráfico inseridos na mão:
<html> <head> <script type="text/javascript" src="js/loader.js"></script> <script type="text/javascript"> google.charts.load('current', {'packages':['corechart']}); google.charts.setOnLoadCallback(drawChart); function drawChart() { var data = google.visualization.arrayToDataTable([ ['TimeStamp', 'FT001', 'FT002'], ['2019-04-10 10:24:09', 300, 400], ['2019-04-10 10:25:09', 600, 460], ['2019-04-10 10:26:09', 500, 1120], ['2019-04-10 10:27:09', 550, 540] ]); var options = { title: 'Company Performance', hAxis: {title: 'TimeStamp', titleTextStyle: {color: '#333'}}, vAxis: {minValue: 0}, backgroundColor: '#E4E4E4', }; var chart = new google.visualization.AreaChart(document.getElementById('chart_div')); chart.draw(data, options); } </script> </head> <body> <div id="chart_div" style="width: 100%; height: 500px"></div> </body> </html> gostaria de saber como busco os dados do Banco de Dados Mysql.
-
Por shriukan
Olá, estou precisando gerar alguns graficos dinâmicos, que puxem dados constantemente do meu BD e mostre no gráfico!!!
Teoricamente essa att deverá ser feita a cada 5m, passando assim os novos dados, mas não sei como posso fazer pra que ele pegue essas informações de forma constante, se alguem puder me ajudar, agradeço muito!!!
-
Por teteuvec
Prezados boa tarde,
Estou tentando escrever na tela o resultado de um select na tela utilizando WHILE, porém está entrando em loop infinito e gostaria de ajuda para acertar a sintaxe desta técnica.
Código apenas com 1 WHILE
<?php $_SESSION['DB_base'] = 'tupa'; $_SESSION['table_base'] = 'people_records'; $query_Recordset2 = "SELECT * FROM {$_SESSION['table_base']} WHERE `link_record` = {$data1['id']} AND `record_caracter_id` = 1 order by {$_SESSION['id_base']} DESC"; $Recordset2 = mysqli_query($connect, $query_Recordset2) or die(mysqli_error($connect)); $row_Recordset2 = mysqli_fetch_assoc($Recordset2); $totalRows_Recordset2 = mysqli_num_rows($Recordset2); while($Recordset2 = mysqli_fetch_assoc($Recordset2)) { echo "Contato: ".$Recordset2["name"]."</br>"; echo "CPF/CNPJ: ".$Recordset2["cpf_cnpj"]."</br>"; echo "e-mail: ".$Recordset2["email"]."</br>"; echo "Celular: ".$Recordset2["cellphone"]."</br>"; echo "Telefone: ".$Recordset2["telephone"]."</br>"; echo "Documento de identificação: ".$Recordset2["name"]."</br>"; echo "</br>"; }?>
Código inteiro:
<?php session_start(); $_SESSION['last_page'] = $_SERVER['PHP_SELF']; $_SESSION['del_message'] = 'Deseja excluir o cliente '; $_SESSION['DB_base'] = 'tupa'; $_SESSION['table_base'] = 'people_records'; $_SESSION['id_base'] = 'id'; require_once('connections.php'); $query_Recordset1 = "SELECT * FROM {$_SESSION['table_base']} WHERE record_caracter_id = '0' order by {$_SESSION['id_base']} DESC"; $Recordset1 = mysqli_query($connect, $query_Recordset1) or die(mysql_error()); $row_Recordset1 = mysqli_fetch_assoc($Recordset1); $totalRows_Recordset1 = mysqli_num_rows($Recordset1); ?> <!doctype html> <html lang='pt-br'> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Tupã - Serviços de Engenharia</title> <link href='css/sistema.css' rel='stylesheet' type='text/css' media='all'> <style type="text/css"> #cnpj { display: none; } #contato { display: none; } #endereco { display: none; } </style> </head> <body> <fieldset> <legend>Gerenciamento de Clientes</legend> <table id="tabela"> <thead> <tr> <th>Descrição</th> <th>Contato</th> <th>Projetos</th> <th colspan="3">Ação</th> </tr> <tr> <th></th> <th></th> <th></th> <th colspan="3"><input type="submit" value="Filtrar" /> | <input type="button" onclick="javascript: location.href='#rec_openModal'" value="Adicionar" /></th> </tr> </thead> <?php while ($Recordset1 = $row_Recordset1){?> <tr> <td bgcolor="#F5F5F5"><p> Código: <?php echo $Recordset1['id']; ?> <br /> Cliente: <?php echo $Recordset1['name']; ?> <br /> CPF/CNPJ: <?php echo $Recordset1['cpf_cnpj']; ?> <br /> e-mail: <?php echo $Recordset1['email']; ?> <br /> Celular: <?php echo $Recordset1['cellphone']; ?> <br /> Telefone: <?php echo $Recordset1['telephone']; ?> <br /> Documento de identificação: <?php if(file_exists('imagens/clients/energy_bill/'.$Recordset1['id'].'.jpg')) { echo 'Documento de identificação: <a href=imagens/clients/energy_bill/'.$Recordset1['id'].'.jpg target="_blank"><img src="imagens/view.png" width="24" height="24">'; } else { echo 'Documento de identificação: indisponível'; } ?> </p></td> <td bgcolor="#F5F5F5"><?php $_SESSION['DB_base'] = 'tupa'; $_SESSION['table_base'] = 'people_records'; $query_Recordset2 = "SELECT * FROM {$_SESSION['table_base']} WHERE `link_record` = {$data1['id']} AND `record_caracter_id` = 1 order by {$_SESSION['id_base']} DESC"; $Recordset2 = mysqli_query($connect, $query_Recordset2) or die(mysqli_error($connect)); $row_Recordset2 = mysqli_fetch_assoc($Recordset2); $totalRows_Recordset2 = mysqli_num_rows($Recordset2); while($Recordset2 = mysqli_fetch_assoc($Recordset2)) { echo "Contato: ".$Recordset2["name"]."</br>"; echo "CPF/CNPJ: ".$Recordset2["cpf_cnpj"]."</br>"; echo "e-mail: ".$Recordset2["email"]."</br>"; echo "Celular: ".$Recordset2["cellphone"]."</br>"; echo "Telefone: ".$Recordset2["telephone"]."</br>"; echo "Documento de identificação: ".$Recordset2["name"]."</br>"; echo "</br>"; }?> </td> <td bgcolor="#F5F5F5"><?php $_SESSION['DB_base'] = 'tupa'; $_SESSION['table_base'] = 'projects_link_tpm'; $query_Recordset3 = "SELECT * FROM {$_SESSION['table_base']} where people_record_id = {$row_Recordset1['id']} order by {$_SESSION['id_base']} DESC"; $Recordset3 = mysqli_query($connect, $query_Recordset3) or die(mysqli_error($connect)); $row_Recordset3 = mysqli_fetch_assoc($Recordset3); $totalRows_Recordset3 = mysqli_num_rows($Recordset3); while($data3 = mysqli_fetch_assoc($Recordset3)) { echo "Projeto: ".$Recordset3["id"]."</br>"; echo "</br>"; }?> </td> <td width="3%" bgcolor="#F5F5F5"><form action="mysql/update_process.php" method="POST"> <input type="hidden" name="update_process" value="<?php echo $row_Recordset1[$_SESSION['id_base']] ?>"> <input type="image" name="submit" src="imagens/edit.png" width="24" height="24"> </form></td> <td bgcolor="#F5F5F5"><form action="mysql/del_process.php" method="POST"> <input type="hidden" name="delete_process" value="<?php echo $row_Recordset1[$_SESSION['id_base']] ?>"> <input type="hidden" name="delete_register" value="<?php echo $row_Recordset1['name'] ?>"> <input type="image" name="submit" src="imagens/delete.png" width="24" height="24"> </form></td> </tr> <?php }?> </table> </fieldset> <div id="rec_openModal" class="modalDialog"> <div> <a class="close" title="Fechar" href="#close">X</a> <fieldset> <legend>Realizar cadastro</legend> <br> <label>Modalidade:</label> <select name="modality" onChange="mostraDiv(this.value)"> <option value="1">Cliente CPF</option> <option value="2">Cliente CNPJ</option> <option value="3">Contato de cliente</option> <option value="4">Endereço de cliente</option> </select> <br /> <div id="cpf"> <form action="mysql/insert_process.php" method="post" id='1'> <br> <label>Nome: </label> <input name='name' type='text' /><br /> <br> <label>CPF: </label> <input name='cpf_cnpj' type='number' data-mask='000.000.000-00' /><br /> <br> <label>e-mail: </label> <input name='email' type='text' /><br /> <br> <label>Celular: </label> <input name='cellphone' type='text' data-mask="(00)0000-0000" /><br /> <br> <label>Telefone: </label> <input name='telephone' type='text' data-mask='(00)00000-0000' autocomplete='off' /><br /> <br> <label>Documento de identificação: </label> <input type='file' name='doc_id'><br /> <INPUT TYPE="hidden" NAME="record_caracter_id" VALUE="0"><INPUT TYPE="hidden" NAME="action" VALUE="0"> <br> <label><input type="submit" value="Cadastrar" /> </label><br /> </form> </div> <div id="cnpj"> <form action="mysql/insert_process.php" method="post" id='2'> <br> <label>Nome da empresa: </label> <input name='name' type='text' /><br /> <br> <label>CNPJ: </label> <input name='cpf_cnpj' type='text' data-mask="00.000.000/0000-00" /><br /> <br> <label>e-mail: </label> <input name='email' type='email' /><br /> <br> <label>Celular: </label> <input name='cellphone' type='text' data-mask="00000-000" /><br /> <br> <label>Telefone: </label> <input name='telephone' type='text' /><br /> <br> <label>Documento de identificação: </label> <input name='doc_id' type='file' /><br /> <INPUT TYPE="hidden" NAME="record_caracter_id" VALUE="0"><INPUT TYPE="hidden" NAME="action" VALUE="0"> <br> <label><input type="submit" value="Cadastrar" /> </label><br /> </form> </div> <div id="contato"> <form action="mysql/insert_process.php" method="post" id='3'> <br> <label>Nome: </label> <input name='name' type='text' /><br /> <br> <label>cpf: </label> <input name='cpf' type='number' data-mask='000.000.000-00' /><br /> <br> <label>e-mail: </label> <input name='email' type='text' /><br /> <br> <label>Celular: </label> <input name='cellphone' type='text' data-mask="(00)0000-0000" /><br /> <br> <label>Telefone: </label> <input name='telephone' type='text' data-mask='(00)00000-0000' autocomplete='off' /><br /> <br> <label>Documento de identificação: </label> <input type='file' name='doc_id'><br /> <INPUT TYPE="hidden" NAME="record_caracter_id" VALUE="1"><br> <label>Contato do cliente </label> <select name="link_record"> <?php while ($data = mysqli_fetch_array($Recordset1)) { echo("<option value='".$data['id']."'>".$data['name']."</option>"); } ?> </select><br /> <INPUT TYPE="hidden" NAME="action" VALUE="0"> <br> <label><input type="submit" value="Cadastrar" /> </label><br /> </form> </div> <div id="endereco"> <form action="mysql/insert_process.php" method="post" id='4'> <br> <label>CEP: </label> <input name='cep' type='text' /><br /> <br> <label>Logradouro: </label> <input name='address' type='text' data-mask="00000-000" autocomplete="off" /><br /> <br> <label>Número: </label> <input name='number' type='text' /><br /> <br> <label>Bairro: </label> <input name='neighborhood' type='text' /><br /> <br> <label>Cidade/UF: </label> <input name='city' type='text' /><input name='uf' type='text' /><br /> <INPUT TYPE="hidden" NAME="record_caracter_id" VALUE="4"><INPUT TYPE="hidden" NAME="action" VALUE="1"> <br> <label><input type="submit" value="Cadastrar" /> </label><br /> </form> </div> </fieldset> </div> </div> </body> </html> <?php mysqli_free_result($Recordset1); mysqli_free_result($Recordset2); mysqli_free_result($Recordset3); ?>
-