1){ $offset = $limit * ($page - 1); $offset_str = ", $offset"; } else { $offset_str = ''; } if ($category == 'all'){ $where = ''; } else { $category_sql = "SELECT `category_id` FROM `pricecategory` WHERE `categoryslug` = '$category' LIMIT 1"; $category = db_get($category_sql); if (isset($category['category_id'])) { $category_id = $category['category_id']; $where = "WHERE `category_id` = $category_id"; } } $sql_books = "SELECT * FROM `price` $where ORDER BY `price_id` DESC LIMIT $limit $offset_str"; return db_get($sql_books); }