Valeu Marcelo, agora está do jeito que eu queria, vou postar o código do jeito que fiz aqui, pode ajudar alguém, está funcionando 100%. Obrigado, <?php
session_start();
if(!isset($_SESSION['loginSession']) AND !isset($_SESSION['senhaSession'])){
echo("<script type='text/javascript'> alert('Você precisa estar logado para acessar esta página !!!'
); location.href='login.php';</script>");
exit;
}
?>
<!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>Documento sem título</title>
</head>
<body>
<table width="800" border="0" align="center" cellpadding="0" cellspacing="5">
<tr>
<td bgcolor="#FFFFFF"><form id="form1" name="form1" method="post" action="">
<label for="textfield"></label>
<input type="text" name="palavra" id="palavra" />
<input type="submit" name="button" id="button" value="Buscar" />
</form></td>
</tr>
<tr>
<td> </td>
</tr>
<tr>
<td height="19"><table width="800" border="0" cellspacing="2" cellpadding="0">
<tr>
<td width="32" align="center" bgcolor="#CCCCCC">id</td>
<td width="175" align="center" bgcolor="#CCCCCC">nome</td>
<td width="100" align="center" bgcolor="#CCCCCC">data nascimento</td>
<td width="30" align="center" bgcolor="#CCCCCC">ddd</td>
<td width="55" align="center" bgcolor="#CCCCCC">telefone</td>
<td width="30" align="center" bgcolor="#CCCCCC">ddd</td>
<td width="55" align="center" bgcolor="#CCCCCC">telefone</td>
<td width="30" align="center" bgcolor="#CCCCCC">ddd</td>
<td width="55" align="center" bgcolor="#CCCCCC">telefone</td>
<td width="40" align="center" bgcolor="#CCCCCC">sexo</td>
<td width="50" align="center" bgcolor="#CCCCCC">login</td>
<td width="50" align="center" bgcolor="#CCCCCC">senha</td>
<td width="48" align="center" bgcolor="#CCCCCC">editar</td>
<td width="50" align="center" bgcolor="#CCCCCC">excluir</td>
</tr>
<?php
include "funcoes.php";
if (isset($_POST['palavra'])){//evita erro Undefined index
$busca = $_POST['palavra'];// palavra que o usuario digitou
$busca_query = mysql_query("SELECT * FROM cadastro WHERE nome LIKE '%$busca%'")or die(mysql_error);//faz a busca com as palavras enviadas
if(empty($busca)){//Se a busca estiver vazia mostra
echo "Preencha o campo de busca";
}else{
if(mysql_num_rows($busca_query) >=1){
// quando existir algo em '$busca_query' ele realizará o script abaixo.
while ($dados = mysql_fetch_array($busca_query)) {
$id = $dados['id'];
$nome = $dados['nome'];
$data_de_nascimento = $dados['data_de_nascimento'];
$telefone_1_1 = $dados['telefone_1_1'];
$telefone_1 = $dados['telefone_1'];
$telefone_2_2 = $dados['telefone_2_2'];
$telefone_2 = $dados['telefone_2'];
$telefone_3_3 = $dados['telefone_3_3'];
$telefone_3 = $dados['telefone_3'];
$sexo = $dados['sexo'];
$login = $dados['login'];
$senha = $dados['senha'];
$id = $dados['id'];
$id = $dados['id'];
// tive que declarar uma por uma pois não é possível lançar um php dentro do outro
?>
<tr>
<td align="center"><?php echo $id; ?></td>
<td align="center"><?php echo $nome; ?></td>
<td align="center"><?php echo $data_de_nascimento; ?></td>
<td align="center"><?php echo $telefone_1_1; ?></td>
<td align="center"><?php echo $telefone_1; ?></td>
<td align="center"><?php echo $telefone_2_2; ?></td>
<td align="center"><?php echo $telefone_2; ?></td>
<td align="center"><?php echo $telefone_3_3; ?></td>
<td align="center"><?php echo $telefone_3; ?></td>
<td align="center"><?php echo $sexo; ?></td>
<td align="center"><?php echo $login; ?></td>
<td align="center"><?php echo $senha; ?></td>
<td align="center"><?php echo $id; ?></td>
<td align="center"><?php echo $id; ?></td>
</tr>
<?php
}
}else{//Não encontrando o registro digitado no bd mostra
echo "Nenhum registro encontrado.";
}
}
}
?>
</table></td>
</tr>
</table>
</body>
</html>