prueba asi
Código PHP:
<?php
$user="root";
$host="localhost";
$password="";
$database = "libros";
$connection = mysql_connect($host,$user,$password)
or die ("couldn't connect to server");
$db = mysql_select_db($database,$connection)
or die ("Couldn't select database");
$where = array();
foreach ($_GET as $key => $value){
if ($_GET [$key]) {
$value= str_replace("'","",$value);
$where[]="'".$key."=".$value."'";
}
}
$sql = "SELECT * FROM libros WHERE ".implode(" AND ",$where).";";
echo $where;
echo '<pre>' . $sql . '</pre>';
?>