phfmiranda 0 Denunciar post Postado Novembro 27, 2010 Boa noite Pessoal, Preciso terminar de colocar em meu site um sistema de busca, fiz desta forma: Pesquisa_Cliente.php <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Untitled Document</title> </head> <body> <form id="Form_pesquisa" name="Form_pesquisa" method="post" action="Mostra_Pesquisa_Cliente.php"> <input name="busca" type="text" id="busca" /> <input type="submit" name="Submit" value="Pesquisar" /> </form> </body> </html> Mostra_Pesquisa.php <?php require_once('../Connections/Conecta.php'); ?> <?php $maxRows_Motra_Pesquisa = 10; $pageNum_Motra_Pesquisa = 0; if (isset($_GET['pageNum_Motra_Pesquisa'])) { $pageNum_Motra_Pesquisa = $_GET['pageNum_Motra_Pesquisa']; } $startRow_Motra_Pesquisa = $pageNum_Motra_Pesquisa * $maxRows_Motra_Pesquisa; $colname_Motra_Pesquisa = "-1"; if (isset($_GET['Nome'])) { $colname_Motra_Pesquisa = (get_magic_quotes_gpc()) ? $_GET['Nome'] : addslashes($_GET['Nome']); } mysql_select_db($database_Conecta, $Conecta); $query_Motra_Pesquisa = sprintf("SELECT * FROM clientes WHERE Nome LIKE '%%%s%%'", $colname_Motra_Pesquisa); $query_limit_Motra_Pesquisa = sprintf("%s LIMIT %d, %d", $query_Motra_Pesquisa, $startRow_Motra_Pesquisa, $maxRows_Motra_Pesquisa); $Motra_Pesquisa = mysql_query($query_limit_Motra_Pesquisa, $Conecta) or die(mysql_error()); $row_Motra_Pesquisa = mysql_fetch_assoc($Motra_Pesquisa); if (isset($_GET['totalRows_Motra_Pesquisa'])) { $totalRows_Motra_Pesquisa = $_GET['totalRows_Motra_Pesquisa']; } else { $all_Motra_Pesquisa = mysql_query($query_Motra_Pesquisa); $totalRows_Motra_Pesquisa = mysql_num_rows($all_Motra_Pesquisa); } $totalPages_Motra_Pesquisa = ceil($totalRows_Motra_Pesquisa/$maxRows_Motra_Pesquisa)-1; ?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Untitled Document</title> </head> <body> <table border="0"> <tr> <td>codigo</td> <td>Nome</td> <td>pai</td> <td>mae</td> <td>Endereco</td> <td>Bairro</td> <td>Cidade</td> <td>Estado</td> <td>Cep</td> <td>Cpf</td> <td>Identidade</td> <td>Data_Nascimento</td> <td>Estado_civil</td> <td>Telefone</td> <td>Celular</td> <td>Observacao</td> <td>Advogado_resp</td> </tr> <?php do { ?> <tr> <td><?php echo $row_Motra_Pesquisa['codigo']; ?></td> <td><?php echo $row_Motra_Pesquisa['Nome']; ?></td> <td><?php echo $row_Motra_Pesquisa['pai']; ?></td> <td><?php echo $row_Motra_Pesquisa['mae']; ?></td> <td><?php echo $row_Motra_Pesquisa['Endereco']; ?></td> <td><?php echo $row_Motra_Pesquisa['Bairro']; ?></td> <td><?php echo $row_Motra_Pesquisa['Cidade']; ?></td> <td><?php echo $row_Motra_Pesquisa['Estado']; ?></td> <td><?php echo $row_Motra_Pesquisa['Cep']; ?></td> <td><?php echo $row_Motra_Pesquisa['Cpf']; ?></td> <td><?php echo $row_Motra_Pesquisa['Identidade']; ?></td> <td><?php echo $row_Motra_Pesquisa['Data_Nascimento']; ?></td> <td><?php echo $row_Motra_Pesquisa['Estado_civil']; ?></td> <td><?php echo $row_Motra_Pesquisa['Telefone']; ?></td> <td><?php echo $row_Motra_Pesquisa['Celular']; ?></td> <td><?php echo $row_Motra_Pesquisa['Observacao']; ?></td> <td><?php echo $row_Motra_Pesquisa['Advogado_resp']; ?></td> </tr> <?php } while ($row_Motra_Pesquisa = mysql_fetch_assoc($Motra_Pesquisa)); ?> </table> </body> </html> <?php mysql_free_result($Motra_Pesquisa); ?> porem quando faço a pesquisa não me retorna nada. Obrigado Compartilhar este post Link para o post Compartilhar em outros sites
Fernando C 128 Denunciar post Postado Novembro 29, 2010 olha, antes d + nada observe q o teu form esta direcionando à pg "Mostra_Pesquisa_Cliente.php" e a pg a você postou é outra.. d qqer forma, aqui está bem explicado; verifique: http://www.mxstudio.com.br/dreamweaver/sistema_de_pesquisa_com_bd/ Compartilhar este post Link para o post Compartilhar em outros sites
phfmiranda 0 Denunciar post Postado Dezembro 8, 2010 Cara eu segui este tutorial porem dá o seguinte erro: Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in /home/xxxxxx/public_html/xxxxxxx/xxxxx/Resultado.php on line 41 Pesquisa_Cliente.php <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Untitled Document</title> </head> <body> <form id="Pesquisa" name="Pesquisa" method="get" action="Resultado.php"> <input name="busca" type="text" id="busca" /> <input type="submit" name="Submit" value="Pesquisar" /> </form> </body> </html> Resultado.php <table border="0"> <tr> <td>codigo</td> <td>Nome</td> <td>pai</td> <td>mae</td> <td>Endereco</td> <td>Bairro</td> <td>Cidade</td> <td>Estado</td> <td>Cep</td> <td>Cpf</td> <td>Identidade</td> <td>Data_Nascimento</td> <td>Estado_civil</td> <td>Telefone</td> <td>Celular</td> <td>Observacao</td> <td>Advogado_resp</td> </tr> <?php do { ?> <tr> <td><?php echo $row_Resultado['codigo']; ?></td> <td><?php echo $row_Resultado['Nome']; ?></td> <td><?php echo $row_Resultado['pai']; ?></td> <td><?php echo $row_Resultado['mae']; ?></td> <td><?php echo $row_Resultado['Endereco']; ?></td> <td><?php echo $row_Resultado['Bairro']; ?></td> <td><?php echo $row_Resultado['Cidade']; ?></td> <td><?php echo $row_Resultado['Estado']; ?></td> <td><?php echo $row_Resultado['Cep']; ?></td> <td><?php echo $row_Resultado['Cpf']; ?></td> <td><?php echo $row_Resultado['Identidade']; ?></td> <td><?php echo $row_Resultado['Data_Nascimento']; ?></td> <td><?php echo $row_Resultado['Estado_civil']; ?></td> <td><?php echo $row_Resultado['Telefone']; ?></td> <td><?php echo $row_Resultado['Celular']; ?></td> <td><?php echo $row_Resultado['Observacao']; ?></td> <td><?php echo $row_Resultado['Advogado_resp']; ?></td> </tr> <?php } while ($row_Resultado = mysql_fetch_assoc($Resultado)); ?> </table> <?php require_once('../Connections/Conecta.php'); ?> <?php $maxRows_Resultado = 10; $pageNum_Resultado = 0; if (isset($_GET['pageNum_Resultado'])) { $pageNum_Resultado = $_GET['pageNum_Resultado']; } $startRow_Resultado = $pageNum_Resultado * $maxRows_Resultado; $colname_Resultado = "-1"; if (isset($_GET['Nome'])) { $colname_Resultado = (get_magic_quotes_gpc()) ? $_GET['Nome'] : addslashes($_GET['Nome']); } mysql_select_db($database_Conecta, $Conecta); $query_Resultado = sprintf("SELECT * FROM clientes WHERE Nome LIKE '%%%s%%'", $colname_Resultado); $query_limit_Resultado = sprintf("%s LIMIT %d, %d", $query_Resultado, $startRow_Resultado, $maxRows_Resultado); $Resultado = mysql_query($query_limit_Resultado, $Conecta) or die(mysql_error()); $row_Resultado = mysql_fetch_assoc($Resultado); if (isset($_GET['totalRows_Resultado'])) { $totalRows_Resultado = $_GET['totalRows_Resultado']; } else { $all_Resultado = mysql_query($query_Resultado); $totalRows_Resultado = mysql_num_rows($all_Resultado); } $totalPages_Resultado = ceil($totalRows_Resultado/$maxRows_Resultado)-1; ?> <?php mysql_free_result($Resultado); ?> Compartilhar este post Link para o post Compartilhar em outros sites
Fernando C 128 Denunciar post Postado Dezembro 9, 2010 Olha.. pelo jeito você n esta sabendo é como exibir o resultado a finalidade do tuto é pegar a logica de 1 busca (parametro etc.) a 1ª pg ok, você ja viu q é super simples. Na pg de resultado siga os passos nessa ordem: 1 - crie o recordset (perceba q tem 1 botão p/ você testar); depois 2 - exiba os campos; a forma + facil d exibir os campos encontrados é ativar a guia "bindings" e arrastar os campos dinâmicos p/ a area de trabalho (ou clique em "insert", logo abaixo, ok?) tenta ai e qqer coisa retorne Compartilhar este post Link para o post Compartilhar em outros sites
phfmiranda 0 Denunciar post Postado Dezembro 11, 2010 Valeu pela ajuda! Mas eu segui estes passos e agora não apresenta erros, porem não mostra nada. Valeu. Compartilhar este post Link para o post Compartilhar em outros sites
Fernando C 128 Denunciar post Postado Dezembro 13, 2010 uai.. curioso.. a minha esta ok.. tente o seguinte então: 1. apague essa pg resultado.php (lembrando d sempre tomar mt cuidado com maiusculas e minusculas, PHP é "case sensitive"); 2. crie o recordset; no campo filter verifique se você colocou o campo nome, do lado direito mantenha o "contains"; 3. na linha de baixo, atenção: selecione URL parameter e no lado direito digite "busca" (sem aspas). teste (aí no recordset mesmo) e retorne o resultado, ok? caso ainda tenha problema, poste novamente o código da pg resultado.php e certifique-se se você n alterou nada na pg do form. d qqer forma minha pg de resultado ficou assim: <?php require_once('Connections/XXXXX.php'); ?> <?php $colname_Recordset1 = "-1"; if (isset($_GET['busca'])) { $colname_Recordset1 = (get_magic_quotes_gpc()) ? $_GET['busca'] : addslashes($_GET['busca']); } mysql_select_db($database_testemysql, $testemysql); $query_Recordset1 = sprintf("SELECT * FROM TABELA WHERE nome LIKE '%%%s%%'", $colname_Recordset1); $Recordset1 = mysql_query($query_Recordset1, $testemysql) or die(mysql_error()); $row_Recordset1 = mysql_fetch_assoc($Recordset1); $totalRows_Recordset1 = mysql_num_rows($Recordset1); ?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Untitled Document</title> </head> <body> <p>Teste de busca Dreamweaver para Forum Imasters</p> <?php do { ?> <p><?php echo $row_Recordset1['id']; ?> - <?php echo $row_Recordset1['nome']; ?><br /> <?php echo $row_Recordset1['mensagem']; ?> - <?php echo $row_Recordset1['dia']; ?></p> <?php } while ($row_Recordset1 = mysql_fetch_assoc($Recordset1)); ?></body> </html> <?php mysql_free_result($Recordset1); ?> ta beleza.. tenta checar c/ a sua.. lembrando d adaptar nomes da conexão, tabela etc. (no caso, a minha pg retorna 4 campos - ou melhor, os dados d 4 colunas - d 1 livro de visitas: id, nome, mensagem e dia) Compartilhar este post Link para o post Compartilhar em outros sites
phfmiranda 0 Denunciar post Postado Dezembro 19, 2010 Obrigado amigo, segui sua dica e funcionou. Compartilhar este post Link para o post Compartilhar em outros sites
Fernando C 128 Denunciar post Postado Dezembro 20, 2010 beleza.. q bom q deu certo [ ] e sucesso Compartilhar este post Link para o post Compartilhar em outros sites