";
echo "
";
echo "Type | Quantity | Price | Line | Expiration Date | Species | Collection Date | Timestamp |
";
echo "";
while($row != null) {
echo "";
for($i = 1; $i < sizeOf($row); $i++) {
echo "" . $row[$i] . " | ";
}
echo "See Item | ";
echo "
";
$row = mysql_fetch_row($results);
}
echo "";
echo "
";
}
#search each database for the input parameters
if($_POST['category'] == "all") {
if(isset($_GET['search'])) $search_param = $_GET['search'];
if(isset($_POST['search'])) $search_param = $_POST['search'];
$some_results = false;
$item_ids;
mysql_connect("floret.cgrb.oregonstate.edu","lab-inventory-user","lab-inventory-user_pw");
mysql_select_db("lab_inventory");
$date_search = "";
if(isset($_POST['from_date']) && isset($_POST['to_date']) && $_POST['from_date']!="" && $_POST['to_date']!="") {
$date_search = "(time_stamp between '" . $_POST['from_date'] . " 00:00:00' and '" . $_POST['to_date'] . " 23:59:59')";
}
#if no search query was entered, then search only by date
$match_against = "";
if($search_param != "") {
$match_against = "(match(type,line,species) against ('$search_param'))";
}
$and = "";
if($date_search!= "" && $match_against != "") $and = "AND";
$query = "select * from item where $match_against $and $date_search";
$results = mysql_query($query);
$row = mysql_fetch_row($results);
if($row != null) {
$some_results = true;
echo "Your query matched the following items:";
echo "
";
echo "Type | Quantity | Price | Line | Expiration Date | Species | Collection Date | Timestamp | ";
echo "";
while($row != null) {
echo "";
for($i = 1; $i < sizeOf($row); $i++) {
echo "" . $row[$i] . " | ";
}
echo "See Item | ";
echo "
";
$row = mysql_fetch_row($results);
}
echo "";
echo "
";
}
$query = "select * from notes where match(note,curator) against('$search_param')";
$results = mysql_query($query);
$row = mysql_fetch_row($results);
if($row != null) {
$some_results = true;
echo "
Your query matched the following notes:
";
echo "";
echo "Note | Curator | Date | ";
while($row != null) {
echo "";
for($i = 1; $i < sizeOf($row); $i++) {
echo "" . $row[$i] . " | ";
}
echo "See Item | ";
echo "
";
$row = mysql_fetch_row($results);
}
echo "
";
}
$query = "select * from meta where match(msds_link,warranty_info,service,manufacturer) against('$search_param')";
$results = mysql_query($query);
$row = mysql_fetch_row($results);
if($row != null) {
$some_results = true;
echo "
Your query matched the following meta information:
";
echo "";
echo "MSDS Link | Warranty Info | Service | Manufacturer | ";
echo "";
while($row != null) {
for($i = 1; $i < sizeOf($row); $i++) {
echo $row[$i] . "\t";
}
echo "See Item";
echo "
";
$row = mysql_fetch_row($results);
}
echo "";
echo "
";
}
if($some_results==false) {
echo "Sorry, your query found no results!
";
}
} else {
$table;
$param = $_POST['search'];
$additive = "";
$category = $_POST['category'];
$curator_categories = array("name","email");
$location_categories = array("building/room","freezer","shelf","cupboard");
$item_categories = array("type","quantity","price","collection date","expiration date","species","line");
if(in_array($category,$item_categories)) {
$table = "item";
if(isset($_POST['from_date']) && isset($_POST['to_date']) && $_POST['from_date']!="" && $_POST['to_date']!="") {
$additive = "&from_time=" . $_POST['from_date'] . " 00:00:00&to_time=" . $_POST['to_date'] . " 24:59:59";
}
} elseif(in_array($category,$location_categories)) {
$table = "location";
} elseif(in_array($category,$curator_categories)) {
$table = "curator";
}
$url = "search_results.php?table=$table&category=$category¶m=$param" . $additive;
header("Location: $url");
}
?>