Ir para conteúdo
Fórum Script Brasil
  • 0

Recordset - Como definir a busca


keruba

Pergunta

Pessoal estou trabalhando com Mysql... já criei um tabela chamada tutorial_126

Como segui o tutorial tudo funcionou corretamente, porém quiz ir mais além.

na minha busca está declarado da seguinte forma:

SELECT *

FROM tutorial_126

WHERE tutorial_126.nome LIKE %busca%

Porém se existe dois registros com o mesmo nome eles não aparecem.

Só aparece o primeiros registro.. e em minha pesquisa ocorre de haver nomes iguais.. porém o resto do conteudo diferente.

na pagina de retorno da pesquisa o busca_resultado.php está assim.

<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  $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;
}
}

$busca_rsBusca_Resultado = "-1";
if (isset($_GET['busca'])) {
  $busca_rsBusca_Resultado = $_GET['busca'];
}
mysql_select_db($database_localhost, $localhost);
$query_rsBusca_Resultado = sprintf("SELECT * FROM tutorial_126 WHERE tutorial_126.nome LIKE %s", GetSQLValueString("%" . $busca_rsBusca_Resultado . "%", "text"));
$rsBusca_Resultado = mysql_query($query_rsBusca_Resultado, $localhost) or die(mysql_error());
$row_rsBusca_Resultado = mysql_fetch_assoc($rsBusca_Resultado);
$totalRows_rsBusca_Resultado = mysql_num_rows($rsBusca_Resultado);
?><!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=utf-8" />
<title>Untitled Document</title>
</head>

<body>
<table width="1015" border="1">
  <tr>
    <td width="307" height="34"><?php echo $row_rsBusca_Resultado['nome']; ?></td>
    <td width="295"><?php echo $row_rsBusca_Resultado['descricao']; ?></td>
    <td width="391"><?php echo $row_rsBusca_Resultado['url']; ?></td>
  </tr>
</table>
<p>&nbsp;</p>
</body>
</html>
<?php
mysql_free_result($rsBusca_Resultado);
?>

Quero saber o porque que ele não joga na tela os nomes iguais.

Espero um solução para isso! VllllWW GALERA

Link para o comentário
Compartilhar em outros sites

0 respostass a esta questão

Posts Recomendados

Até agora não há respostas para essa pergunta

Participe da discussão

Você pode postar agora e se registrar depois. Se você já tem uma conta, acesse agora para postar com sua conta.

Visitante
Responder esta pergunta...

×   Você colou conteúdo com formatação.   Remover formatação

  Apenas 75 emoticons são permitidos.

×   Seu link foi incorporado automaticamente.   Exibir como um link em vez disso

×   Seu conteúdo anterior foi restaurado.   Limpar Editor

×   Você não pode colar imagens diretamente. Carregar ou inserir imagens do URL.



  • Estatísticas dos Fóruns

    • Tópicos
      152,1k
    • Posts
      651,8k
×
×
  • Criar Novo...