April 21, 2009

Search Our Inventory

echo “\r\n”; echo “Cover Image\r\n“; } else echo “Picture Unavailable\r\n”; } else echo “Picture Unavailable\r\n”; } function DateConversion($date) { list($year, $month, $day) = split(‘[-.-]’, $date); $date = “$month/$day/$year”; return $date; } function HighlightSearchTerms($text, $search_criteria) { if (empty($search_criteria)) return $text; else foreach ($search_criteria as $word) { $word = preg_quote($word); $text = preg_replace(“/($word)/i”, ‘\1‘, $text); } return $text; } function IsOptionSelected ($optionValue, $testValue) { if ($optionValue === $testValue) echo ” selected=’selected'”; } function NavigationBar ($current, $last) { if (is_numeric($last) && $last > 1) { ?>
} function OpenConnection () { session_name(); $link = mysqli_connect(“localhost”, “Visigoth”, “medussa”, “CHB”); if (mysqli_connect_errno($link)) echo “Failed to connect to MySQL: ” . mysqli_connect_error() . ” \r\n”; //Check connection else { mysqli_set_charset ($link , “utf8”); //define the character set to be used. return $link; } } function RetrieveData ($var, $nullifier = NULL) { if (isset($_POST[$var])) return stripslashes($_POST[$var]); elseif (!$nullifier && !empty($_SESSION[$var])) return stripslashes($_SESSION[$var]); else return FALSE; } $db = OpenConnection(); //Open the session and connect to the database if (!empty($_GET[‘pagenumber’])) $pagenumber = $_GET[‘pagenumber’]; //Find the current page number. else $pagenumber = 1; //Set to page 1 if there is none. if (RetrieveData(‘category’)) $category = RetrieveData(‘category’); //Retrieve $_POST or $_SESSION data, if any if (RetrieveData(‘field’)) $field = RetrieveData(‘field’); // . if (RetrieveData(‘query’)) $query = RetrieveData(‘query’); // . if (RetrieveData(‘sortby’)) $sortby = RetrieveData(‘sortby’); // . if (RetrieveData(‘sql’)) $sql = RetrieveData(‘sql’); // . $bracketPattern = array(‘/</’, ‘/>/’); $bracketReplace = array(‘<‘, ‘>’); if ($query) $safeQuery = preg_replace($bracketPattern, $bracketReplace, $query); //TESTING //echo “\r\n”; //if ($category) echo “\$category = ” . $category . ” \r\n”; //if ($field) echo “\$field = ” . $field . ” \r\n”; //if ($query) echo “\$query = ” . $query . ” \r\n”; //if ($sortby) echo “\$sortby = ” . $sortby . ” \r\n”; //if ($sql) echo “\$sql = ” . $sql . ” \r\n”; //echo ” \r\n\r\n”; //END TESTING ?> [View New Arrivals]
Search:
Search By:
Browse By Category:
Sort By:
if ($_GET[‘searchtype’] == “recent”) { unset($_SESSION[‘field’], $_SESSION[‘sortby’], $_SESSION[‘query’], $_SESSION[‘category’]); $_SESSION[‘searchtype’] = “recent”; $EndDate = date(‘Y-m-d’); $StartDate = date(“Y-m-d”, mktime(0,0,0, date(m), date(d)-2,date(Y))); $sql = “SELECT * FROM Inventory WHERE date BETWEEN ‘$StartDate’ AND ‘$EndDate’ ORDER BY Author, Title”; } else { if (!empty($query)) { $query = trim(preg_replace(‘/[\\\\|\.,\/[\]\^<>\?!\{}@;:#$%&*_=+)(]+/’, “”, $query)); $_SESSION[‘query’] = addslashes($query); $testQuery = TRUE; $searchString = “”; $ProscribedList = array(“an”, “and”, “not”, “of”, “on”, “or”, “the”, “to”, “in”); $queryArray = PREG_SPLIT(“/[\s-]+/”, strtolower($query)); foreach ($queryArray as $queryTerm) { if (strlen($queryTerm)>1 && !in_array($queryTerm, $ProscribedList)) { $modifiedTerm = preg_replace(“/’/”, “””, trim($queryTerm)); $highlightArray[] = trim($queryTerm); if (strlen($like) > 0) { $like .= ” AND “; $searchString .= ” “; } $like .= “$field LIKE ‘%$modifiedTerm%’ “; $searchString .= $queryTerm; } //TESTING //echo “\r\n\$queryTerm = ” . $queryTerm . ” \r\n”; //if ($modifiedTerm) echo “\r\n\$modifiedTerm = ” . $modifiedTerm . ” \r\n”; //END TESTING unset($modifiedTerm); } } else { unset($_SESSION[‘query’]); $testQuery = FALSE; } if (!empty($category)) { $_SESSION[‘category’] = $category; $testCategory = TRUE; $categoryString = “Category LIKE ‘” . $category . “‘”; } else { unset($_SESSION[‘category’]); $testCategory = FALSE; } if ($testQuery || $testCategory) { $_SESSION[‘field’] = $field; $_SESSION[‘sortby’] = $sortby; unset($_SESSION[‘searchtype’]); $sql = “SELECT * FROM Inventory WHERE “; if ($testQuery && $testCategory) $sql .= $like . ” AND ” . $categoryString; elseif ($testQuery) $sql .= $like; elseif ($testCategory) $sql .= $categoryString; if (isset($sql)) $sql .= ” ORDER BY ” . $sortby . ” ASC”; //TESTING //echo “\r\n”; //echo “\$sql = ” . $sql . ” \r\n”; //echo “\$query = ” . ($query) . (” “); //echo “\$_SESSION[‘query’] = ” . $_SESSION[‘query’] . ” \r\n”; //echo “\$queryArray = “; //print_r($queryArray); //echo ” \r\n”; //echo “\$highlightArray = “; //print_r($highlightArray); //echo ” \r\n“; //END TESTING } } if (!$testQuery && !$testCategory && empty($_GET[‘pagenumber’]) && empty($_GET[‘searchtype’])) unset($sql, $_POST[‘query’], $_POST[‘category’], $_SESSION[‘query’], $_SESSION[‘category’]); if (isset($sql)) { $_SESSION[‘sql’] = $sql; //Store the sql query for later use $num_display = 10; //Set the number of results to display per page $resultsFull = mysqli_query($db, $sql); $num_rows = mysqli_num_rows($resultsFull); //find the total number of records $lastpage = ceil($num_rows / $num_display); //figure the number of pages needed if (($pagenumber < 1) || (empty($pagenumber))) $pagenumber = 1; //Make sure the page number is not outside of the results set elseif ($pagenumber > $lastpage) $pagenumber = $lastpage; $limitedsql = $sql . ” LIMIT ” . ($pagenumber-1)*$num_display . “, ” . $num_display; $results = mysqli_query($db, $limitedsql); //Repeat the query, getting only the results to be displayed if ($_SESSION[‘searchtype’] == “recent”) { echo(”

” . $num_rows . ” Recent Acquisitions from ” . DateConversion(date(“Y-m-d”, mktime(0,0,0, date(m), date(d)-2,date(Y)))) . ” to ” . DateConversion(date(“Y-m-d”)) . “

“); } else { echo ”

There “; if ($num_rows == 1) echo “is “; elseif (num_rows > 1) echo “are “; elseif ($num_rows == 0) echo “no “; if ($num_rows > 0) echo $num_rows; echo ” book”; if ($num_rows <> 1) echo “s”; if (!empty($searchString)) echo ” matching your $field search for ‘$query'”; if (!empty($category)) echo ” in the $category category”; echo “.

“; } ?>

Cover images are provided through the OpenLibrary project, and may not be an exact match with the physical copy in our store. Clicking on any image will take you to the OpenLibrary information page for that book.

New books arrive daily, so please check back again!

   
Author: ISBN: Condition: Price: Qty: Category: Binding: Description: [Reserve Book] [View Reservations]
  Please use our shipping form to let us know when you plan on picking up your books in person or if you would like the books shipped to you. Visa, MasterCard and Discover gladly accepted over the phone for shipping customers. Call 303-837-0700 for shipping services or if you have any questions. Learn about our shipping services here. shelf
We get new books all the time. Check back regularly.

One thought on “Search Our Inventory”

Comments are closed.