$dsn = "mysql://mardust_user:Fish99@localhost/mardust_MD";
/* 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 */
$mfg_menu = "";
?>
Report Page
Updated as of
| PART NO |
MFG |
DESCRIPTION |
P |
$match_ids = array();
/* do we have search terms? */
if( $_GET['kw'] ) {
$search = new Search;
$search->setLimit(10000);
list($count,$match_ids) = $search->kwSearch($_GET['kw']);
}
/* start the query array */
$q_arr = array();
/* check for mfg limit */
if( $_GET['MFG'] ) {
$where_limit_arr[] = "MFG=?";
$q_arr[] = $_GET['MFG'];
}
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 `SURPARTS` $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_NUMBER'], $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['PART_NO']?> |
=$nrow['MFG']?> |
=$nrow['DESCRIPTIN']?> |
=$nrow['MD_NUMBER']?> |
;
}
}
}
/* display nothing */
if( !count($rows) ) {
?>
| There are no parts that match your search specifications. |
;
}
?>