tengo una base de datos de una biblioteca programada en php que, seleccionando el autor, la editorial y el idioma, me manda a una pag. en la que debería mostrarme todos los resultados que coincidan con esa pag., pero me da error.
Este es el código:
Código PHP:
<html>
<head><title>Lista de libros</title></head>
<body>
<h1>Listado de libros</h1>
<p><a href="libros.php">Nueva búsqueda</a></p>
<?php
$bd=mysql_connect('localhost', 'usuario', 'contraseña');
mysql_select_db("biblioteca");
$select="SELECT DISTINCT libros.ID, libros.TID, libros.LID, libros.EID, titulo, autores.ID, autor,
editorial.EID, nombre, idioma.LID, idioma";
$from="WHERE libros, autores, editorial, idioma";
$where="WHERE libros.TID > 0 AND autores.ID=libros.ID AND editorial.EID=libros.EID AND
idioma.LID=libros.LID";
if ($aid != "") {
$where .= " AND libros.ID=$aid";
}
if ($eid != "") {
$where .= " AND EID=$eid";
}
if ($lid != "") {
$where .= " AND idioma.LID=$lid";
}
if ($searchtext != "") {
$where .= " AND titulo LIKE '%$searchtext%'";
}
?>
<table border="1">
<tr>
<th>Título</th><th>Autor</th><th>Idioma</th><th>Editorial</th>
</tr>
<?php
$bus=mysql_query($select . $from . $where);
if (!$bus) {
echo("</table>");
echo("<p>Error!<br>". "Error: " . mysql_error() . "</p>");
exit();
}
while ($bu=mysql_fetch_array($bus)) {
echo("<tr valign='top'>\n");
$id=$bu["id"];
$tit=htmlspecialchars($bu["titulo"]);
$nombre=htmlspecialchars($bu["nombre"]);
$idio=htmlspecialchars($bu["idioma"]);
$edi=htmlspecialchars($bu["editorial"]);
echo("<td>$tit</td>\n");
echo("<td>$nombre</td>\n");
echo("<td>$idio</td>\n");
echo("<td>$edi</td>\n");
echo("</tr>\n");
}
?>
</table>
</body>
</html>
Gracias y saludos.