Estou com um probleminha para exibir os resultados, quando faço a busca ele não mostra os resultados, mas mostra corretamente o número de registros. arquivo: class.search.php <?
class conexao {
var $hostdb = "localhost";
var $userdb = "root";
var $passdb = "";
var $namedb = "pcworld";
function conexao() {
$conexao = mysql_connect($this->hostdb,$this->userdb,$this->passdb);
mysql_select_db($this->namedb,$conexao);
}
}
class busca extends conexao {
var $k;
var $tabela = "tb_cli_cliente";
var $coluna = "cli_nome";
var $sql;
var $total;
function busca($palavra) {
$this->k = $palavra;
}
function cCon() {
$conexao = new conexao;
}
function pesquisa(){
$this->cCon();
$this->sql = mysql_query("SELECT * FROM $this->tabela WHERE $this->coluna LIKE '%$this->k%'")
or die(mysql_error());
}
function totalResultados() {
$this->cCon();
$this->total = mysql_num_rows($this->sql);
}
function imprimeResultados(){
$this->cCon();
echo "Resultados encontrados: " . $this->total;
echo "<br><br>";
while($resultados = mysql_fetch_array($this->sql))
{
$novo = "<strong><span style=\"color: #FF0000;\">" . $this->k . "</span></strong>";
if(eregi($this->k,$resultados['resposta'])){
$resultados['resposta'] = str_replace($this->k,$novo,$resultados['resposta']);
}
echo $resultados['resposta'];
echo "<br>-------------------------------------------------------------<br>";
}
}
}
?>
arquivo: search.php
<?php
include("class.busca.php");
if($_GET['acao'] == "buscar") {
$busca = new busca($_POST['palavra']);
$busca->pesquisa();
$busca->totalResultados();
$busca->imprimeResultados();
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR...ransitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Busca</title>
</head>
<body>
<form id="form1" name="form1" method="post" action="?acao=buscar">
<input name="palavra" type="text" id="palavra" />
<input type="submit" name="Submit" value="Submit" />
</form>
</body>
</html>