Usamos cookies para medir audiência e melhorar sua experiência. Você pode aceitar ou recusar a qualquer momento. Veja sobre o iMasters.
Estou montando um banco de dados e nao estou consiguindo fazer este sistema de busca funcionar da o seguinte erro:
Warning: mysql_fetch_row() expects parameter 1 to be resource, boolean given in C:\wamp\www\auto_center\busca.php on line 65
agora todo o codigo do busca.php
<?php
mysql_connect("localhost", "root", ""); mysql_select_db("clientes");
?>
<!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">](http://www.w3.org/1999/xhtml)
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<style>
form{border-botton-style:dashed;}
form, input, select{font: 25px arial; color:#666666;}
input{color: #999; border: solid 3px #999;}, table, td, tr, th{border: solid 1px #CCCCCC;}
.bt_lupa{width: 30px; border:none;}
.col1{width:300px;}
.col2{width:150px; text-align:center;}
.col3{width:200; text-align:left;}
</style>
</head>
<body>
<form method="get" action="">
Busca: <input type="text" size="25" name="busca" />
<select name="tabela" >
<option value="nome">Nome</option>
<option value="cpf">CPF</option>
<option value="dt_nasc">Data de Nascimento</option>
</select>
<input type="image" src="lupa.png" border="0" class="bt_lupa">
<p />
</form>
<?php
$busca = addslashes($_GET['busca']);
$tabela = addslashes($_GET['tabela']);
$SQL = "SELECT nome, cpf, dt_nasc, responsavel
FROM clientes
";
switch($tabela){
case "nome":
$SQL .= "WHERE nome LIKE('%$busca%')";
break;
case "cpf":
$SQL .= "WHERE cpf LIKE('%$busca%')";
break;
case "dt_nasc":
$SQL .= "WHERE dt_nasc LIKE('%$busca%')";
break;
}
$SQL .= "ORDER BY $tabela ASC";
$rs = mysql_query($SQL);
echo '<table>
<tr>
<th class="col1">Nome</th>
<th class="col2">CPF</th>
<th class="col1">Data de Nascimento</th>
<th class="col2">Situação</th>
</tr>';
[b]//linha 65 if (list($cod_cli, $nome, $cpf, $dt_nasc, $resp) = mysql_fetch_row($rs)) {[/b]
while(list($cod_cli, $cpf, $dt_nasc, $resp) = mysql_fetch_row($rs)){
echo "<tr>
<td class=\"col1\">$nome</td>
<td class=\"col2\">$cpf</td>
<td class=\"col3\">$dt_nasc</td>
<td class=\"col3\">$resp</td>
<td><a href=\"detalhe.php?cod=$cod_cli\">Detalhe</a></td>
</tr>";
}
} else {
echo "<tr>
<td colspan=\"4\" align=\"center\">Refine os parâmentros de pesquisa</td>
</tr>";
}
echo '</table>';
?>
</body>
</html>Carregando comentários...