Location: PHPKode > projects > Online Resource Management system > storms/user/user_search_hardware.php
<?php

/************************************************
 *   Hardware search page
 *   maintained by: Raymond Lai
 *   created: 29 Jan 2001
 *   last update: 11 Feb 2001
 *   Input: Nil
 *   Output: Nil
 *   Purpose: To search hardware in the database,
 *            and display the results
 ************************************************/

include("../includes/session_mysql.inc");
include("../includes/global-vars.inc");

session_start();
session_register("user_class");
session_register("username");
session_register("name");
session_register("lang");
session_register("hardware_request_items");

include("$lang.inc");

mysql_connect ($dbhost, $dbuser, $dbpasswd);

//make sure all spaces at the beginning and the end of the keyword string is stripped out
$hardwarename = trim($hardwarename);
//then, explode the whole thing out
$keywords = explode(" ", $hardwarename);

//build the query string
$query = "select hardwareID, hardware_name, hardware_status from hardware where hardware_name like '%$keywords[0]%'";

//if there are multiple keywords, add it against the query string
if(count($keywords) > 1)
{
        for($j=1; $j<count($keywords); $j++)
        {
		if($keywords[$j])
	                $query .= " or hardware_name like '%$keywords[$j]%'";
        }
}

if($sortby)
{
	$query .= " order by $sortby";
}

if($sortorder)
{
	$query .= " $sortorder";
}

//print $query;

// get results 
if($result = mysql_db_query($dbname, $query))
{
	$num_rows = mysql_num_rows($result);
}
else
{
	print "No records found.";
	mysql_free_result($result);
}

?>
<html>
<head>
<title><?php print $msg_browse_hardware_title; ?></title>
<?php print $doc_encoding; ?>
<link rel="stylesheet" href="../style.css" type="text/css">
</head>
<script language="javaScript" type="text/javascript" SRC="../js/details_window.js"></SCRIPT>
<body bgcolor="#FFFFFF" text="#000000" topmargin="0" leftmargin="0" marginwidth="0" marginheight="0" bottommargin="0" rightmargin="0">
<table width="100%" height="100%" border="0" cellspacing="0" cellpadding="0">
        <tr>
		<td width="160" bgcolor="#FFFFFF" valign="top"> 
                        <!--- ©O«×«Y menu¬J¦ì¸m. ­ø¦nÕi©O«×! --->
<?php include("menu.inc"); ?>
			<!--- ¤W­±«YÂ\ menu¬J¦a¤è! --->
		</td>
		<td valign="top"> 
                        <!--- ©O«×¥ý«Y¦U¦ìÂ\ content¬J¦a¤è --->
                        <table width="90%" border="0" cellspacing="0" cellpadding="5">
				<tr valign="top">
					<td colspan="4"><h3 class="heading"><?php print $msg_browse_hardware_title; ?></h3></td>
				</tr>
				<tr>
					<td colspan="2" height="30"><span class="text12px"><?php print $msg_user;?></span><span class="text12pxbold"><?php print $name; ?></span></td><?php
if(!empty($hardware_request_items))
{
?>
					<td height="30" colspan="2"><a class="textlink" href="user_view_hardware_requesttray.php"><?php print $msg_browse_hardware_view_list; ?></a></td>
<?php
}
else
{
?>
					<td height="30" colspan="2">&nbsp;</td>
<?php
}
?>
				</tr>
				<tr>
                                        <td colspan="4"><?php print $msg_browse_hardware_query_string; ?><?php print $hardwarename; ?></td>
				</tr>
                                <tr>
                                        <td colspan="4"><?php printf($msg_browse_hardware_query_result, $num_rows); ?>
                                        </td>
                                </tr>
                                <tr>
                                        <td height="50" valign="middle" width="25%"><?php print $msg_browse_hardware_name_header; ?></td>
					<form action="user_search_hardware.php">
                                                <td width="25%" valign="middle" align="center">
                                                        <input type="text" name="hardwarename">
                                                </td>
                                                <td width="25%" align="left" valign="middle">
                                                        <input type="submit" name="Submit" value="Search">
                                                </td>
					</form>
					<td>&nbsp;</td>
                                </tr>
				<tr>
					<td colspan="3">
						<a class="textlink" href="<?php print "$PHP_SELF?page=$page&sortby=hardware_name"; ?>"><?php print $msg_browse_hardware_name_header; ?></a>&nbsp;&nbsp;
						<a class="textlink" href="<?php print "$PHP_SELF?page=$page&sortby=hardware_name&sortorder=asc"; ?>"><img src="../image/plus.gif" alt="<?php print $msg_plus;?>" border="0"></a>&nbsp;&nbsp;
						<a class="textlink" href="<?php print "$PHP_SELF?page=$page&sortby=hardware_name&sortorder=desc"; ?>"><img src="../image/minus.gif" alt="<?php print $msg_minus; ?>" border="0"></a>
					</td>
					<td>
						<a class="textlink" href="<?php print "$PHP_SELF?page=$page&sortby=hardware_status"; ?>"><?php print $msg_browse_hardware_status_header; ?></a>&nbsp;
						<a href="<?php print "$PHP_SELF?page=$page&sortby=hardware_status&sortorder=asc"; ?>"><img src="../image/plus.gif" alt="<?php print $msg_plus; ?>" border="0"></a>&nbsp;
						<a href="<?php print "$PHP_SELF?page=$page&sortby=hardware_status&sortorder=desc"; ?>"><img src="../image/minus.gif" alt="<?php print $msg_minus; ?>" border="0"></a>&nbsp;
					</td>
				</tr>

<?php
// now you can display the results returned
$rowcolor = $major_color;
while($row = mysql_fetch_array($result))
{
        if($rowcolor == $minor_color)
                $rowcolor = $major_color;
        else
                $rowcolor = $minor_color;
        print "\t\t\t\t<tr bgcolor=\"$rowcolor\">\n";
	print "\t\t\t\t\t<td colspan=\"3\"><a class=\"textlink\" href=\"#\" onClick=\"showDetails('hardware', '" . $row["hardwareID"] . "', 601, 550)\">". $row["hardware_name"] . "</a></td>\n";
if($row["hardware_status"] === "available")
	print "\t\t\t\t\t<td nowrap><a class=\"textlink\" href=\"user_hardware_add2req.php?hardwareid=" . $row["hardwareID"] . "\"><?php print $msg_browse_hardware_add_to_list; ?></a></td>\n";
else
	print "\t\t\t\t\t<td>". $row["hardware_status"] . "</td>\n";
	print "\t\t\t\t</tr>\n";
} 
?>
                        </table>
			<!--- °O¦í, ¥u«Y©O«×!!!! --->
                </td>		
	</tr>
</table>
</body>
</html>
Return current item: Online Resource Management system