
		saitam
		
		(usa Slackware)
		
		Enviado em 19/06/2008 - 16:59h 
		pq não esta pesquisando os livros digitados no campo, mesmo com o bd alimentado?
Segue o script?
<html>
 <head>
  <title> Pesquisa </title>
 </head>
  <body>
  <center>
    <form action="pesquisa_livros.php" method="POST">
       <h2> Pesquisa de livros </h2>
       <input type="radio" name="opcBusca" value="Autor" checked> Autor
       <input type="radio" name="opcBusca" value="Titulo" checked> Titulo
       <br><br>
         Pesquisa:  <input type="text" name="pesq" size="40">
         <input type="submit" name="buscalivros" value="Buscar">
    </form>
  </center>
  </body>
</html>
<?php
include "mysqlconecta.php";
if($_POST['buscalivros'])
{
 $tipo = $_POST['opcBusca']; echo $tipo; echo "<br> " .$pesq; echo "<br>";
 $pesq = $_POST['pesq'];
 if(empty($pesq))
 {
    echo "Erro! campo pesquisa em branco!";
    exit;
 }
 else
 {
        $sql = "select cd_livro,titulo,autor,ibsn,desc_editora,numpag,numedicao from livro l inner join editora e on l.cd_editora=e.cd_editora where $tipo like '$pesq%' ";
        $resultado = mysql_query($sql) or die("Erro na consulta" .mysql_error());
        $linhas = mysql_num_rows($resultado);
        
        if($linhas == 0)
        {
           echo "Nenhum livro encontrado!";
           exit;
        }
        else
        {
                 echo "<table width=100%";
                 echo "<tr>";
                 echo "th>Codigo livro</th>
                       <th>Titulo </th>
                       <th>Autor </th>
                       <th>ISBN </th>
                       <th>Editora </th>
                       <th>Numero de paginas </th>
                       <th>Edicao </th> </tr>";
          if($linhas > 0)
          {
             $cont=0;
             echo "Encontrado(s) $linhas livros na pesquisa $pesq <br><br>";
             for($i=0; i<$linhas; $i++)
             {
                    echo "<td>" .mysql_result($resultado,$i,"cod_livro");
                    echo "<td>" .mysql_result($resultado,$i,"titulo");
                    echo "<td>" .mysql_result($resultado,$i,"autor");
                    echo "<td>" .mysql_result($resultado,$i,"isbn");
                    echo "<td>" .mysql_result($resultado,$i,"desc_editora");
                    echo "<td>" .mysql_result($resultado,$i,"numpag");
                    echo "<td>" .mysql_result($resultado,$i,"numedicao");
                    echo "</tr>\n";
                    echo "</table>";
              }
        }
     }
  }
}
?>
o erro esta na consulta = Unknown column 'cd_livro' in 'field list'
as tabelas são:
create table livro(
cd_livro int,
titulo varchar(100),
autor varchar(100),
isbn varchar(30),
cd_editora int,
numpag int,
numedicao int,
primary key(cd_livro),
foreign key(cd_editora) references editora(cd_editora)
);
create table editora(
cd_editora int,
desc_editora varchar(60),
primary key(cd_editora)
);