Este es el code:
Código PHP:
if (!isset($_GET['buscar'])){
$_pagi_sql = "";
if (isset ($autor) && !($autor == "")) {
$_pagi_sql .= " autor LIKE '%$autor%'";
}
if (isset ($titulo) && !($titulo == "")) {
if (! ($_pagi_sql == "")) {$_pagi_sql .= " AND "; }
$_pagi_sql .= " titulo LIKE '%$titulo%'";
}
if (isset ($tema) && !($tema == "")) {
if (! ($_pagi_sql == "")) {$_pagi_sql .= " AND "; }
$_pagi_sql .= " tema LIKE '%$tema%'";
}
if (isset ($editorial) && !($editorial == "")) {
if (! ($_pagi_sql == "")) {$_pagi_sql .= " AND "; }
$_pagi_sql .= " descripcion LIKE '%$editorial%'";
}
if (isset ($precio) && !($precio == "")) {
if (! ($_pagi_sql == "")) {$_pagi_sql .= " AND "; }
$_pagi_sql .= " precio LIKE '%$precio%'";
}
if (isset ($fecha) && !($fecha == "")) {
if (! ($_pagi_sql == "")) {$_pagi_sql .= " AND "; }
$_pagi_sql .= " descripcion LIKE '%$fecha%'";
}
if (isset ($clave) && !($clave == "")) {
if (! ($_pagi_sql == "")) {$_pagi_sql .= " AND "; }
$_pagi_sql .= " descripcion LIKE '%$clave%' OR titulo LIKE '%$clave%' OR autor LIKE '%$clave%' OR tema LIKE '%$clave%' ";
}
if (!($_pagi_sql == "")) {
$_pagi_sql = "WHERE".$_pagi_sql;
}
$_pagi_sql = "SELECT * FROM libros $_pagi_sql ORDER BY autor ASC";
//if (isset ($bef) && !($bef == "")) {
//if (! ($pagi_sql == "")) {$pagi_sql .= " AND "; }
//$pagi_sql .= " data < '$bef'";
}else{
$_pagi_sql = "SELECT * FROM libros WHERE autor LIKE '%$autor%' AND titulo LIKE '%$titulo%' AND precio LIKE '%$precio%' AND descripcion LIKE '%$fecha%' AND descripcion LIKE '%$clave%' AND descripcion LIKE '%$editorial%' AND tema LIKE '%$tema%' AND titulo LIKE '%$pagi_sql%' AND autor LIKE '%$pagi_sql%' AND descripcion LIKE '%$pagi_sql%' AND tema LIKE '%$pagi_sql%' order by autor asc";
}