$dsn = "mysql://mardust_user:Fish99@localhost/mardust_MD";
$pics = "../SurveyPics";
/* connect to the db */
require_once 'DB.php';
$db =& DB::connect($dsn, $options);
if (DB::isError($db)) { die($db->getMessage()); }
/* prepare the search */
require_once 'Search.php';
if( !Search::test_db() )
Search::make_db();
/* a function to make urls */
function url( $arr = array() ) {
$get = $_GET;
/* control for order reversal */
if( $get['s'] == $arr['s'] ) {
if( $get['o'] == 'asc' )
$arr['o'] = 'desc';
elseif( $get['o'] == 'desc' )
$arr['o'] = 'asc';
else
$arr['o'] = 'desc';
} else
unset($get['o']);
$res = array_merge($get, $arr);
foreach( $res as $k => $v )
$res_text .= "$k=" . urlencode($v) . "&";
$res_text = substr($res_text, 0, -1);
echo "?$res_text";
}
/* make menus */
$brand_menu = "";
$condition_menu = "";
?>
Mar Dustrial Surplus Inventory Report
Updated as of
| MD NUM |
CONFIGURATION |
BRAND |
MODEL |
SIZE |
HP |
TYPE |
RATIO |
CONDITION |
DISPOSITION |
Picture On File |
$match_ids = array();
/* do we have search terms? */
if( $_GET['kw'] ) {
$searched++;
$search = new Search;
$search->setLimit(10000);
list($count,$match_ids) = $search->kwSearch($_GET['kw']);
}
/* if we didn't run a kw search, or we did and it found results, do the rest of the processing */
if( !$searched or ($searched and $count) ) {
/* start the query array */
$q_arr = array();
/* check for brand limit */
if( $_GET['brand'] ) {
$where_limit_arr[] = "brand=?";
$q_arr[] = $_GET['brand'];
}
if( $_GET['condition'] ) {
$where_limit_arr[] = "`condition`=?";
$q_arr[] = $_GET['condition'];
}
if( count($where_limit_arr) )
$where_limit = "where " . join(" and ", $where_limit_arr);
/* get sort order */
if( $_GET['s'] ) {
$order_by = "order by `!`";
$q_arr[] = $_GET['s'];
if( in_array($_GET['o'], array('asc', 'desc')) )
$order_by .= " " . $_GET['o'];
}
/* run the query */
$res = $db->query("select * from `SURVEY` $where_limit $order_by", $q_arr);
if( $res->numRows() ) {
/* first build the match list */
while( $res->fetchInto($row, DB_FETCHMODE_ASSOC) )
if( !count($match_ids) or in_array($row['MD_NUM'], $match_ids) )
$rows[] = $row;
/* then display it */
if( count($rows) ) {
foreach( $rows as $row ) {
foreach( $row as $k => $v )
$nrow[$k] = ($v != "NULL") ? $v : "";
$color = 1 - $color;
$color_text = $color ? "TrOdd" : "TrRows";
?>
| =$nrow['MD_NUM']?> |
=$nrow['CONFIGURATION']?> |
=$nrow['BRAND']?> |
=$nrow['MODEL']?> |
=$nrow['SIZE']?> |
=$nrow['HP@1750RPM']?> |
=$nrow['TYPE']?> |
=$nrow['RATIO']?> |
=$nrow['CONDITION']?> |
=$nrow['DISPOSITION']?> |
= file_exists("../SurveyPics/MD" . $nrow['MD_NUM'] . ".html") ? "YES | " : "" ?>
;
}
}
}
}
/* display nothing */
if( !count($rows) ) {
?>
| There are no parts that match your search specifications. |
;
}
?>