저는 IT 자산 데이터베이스를 디자인하고 있습니다. 여기서는 저작물 ID로 결정된 특정 저작물에 대한 세부 정보를 보는 데 사용되는 페이지 작업 중입니다.
가 여기에 내가 $_GET["id"];
$id
가 null에서 $id
를 잡아, 페이지가로드되지 않습니다. $id
이 데이터베이스 내의 항목과 일치하지 않으면 페이지가로드되지만 자산 테이블은 인쇄되지 않습니다. 두 경우 모두에서
, 나는
가 어떻게 취급 될 것이다 "그 자산 ID에 대한 데이터베이스 항목이 없습니다"와 같은 메시지를 표시 하시겠습니까? 고맙습니다.<?php
/*
* View Asset
*
*/
# include functions script
include "functions.php";
$id = $_GET["id"];
ConnectDB();
$type = GetAssetType($id);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" type="text/css" href="style.css" />
<title>Wagman IT Asset</title>
</head>
<body>
<div id="page">
<div id="header">
<img src="images/logo.png" />
</div>
</div>
<div id="content">
<div id="container">
<div id="main">
<div id="menu">
<ul>
<table width="100%" border="0">
<tr>
<td width="15%"></td>
<td width="30%%"><li><a href="index.php">Search Assets</a></li></td>
<td width="30%"><li><a href="addAsset.php">Add Asset</a></li></td>
<td width="25%"></td>
</tr>
</table>
</ul>
</div>
<div id="text">
<ul>
<li>
<h1>View Asset</h1>
</li>
</ul>
<br />
<?php
switch ($type){
case "Server":
$result = QueryServer($id);
$ServerArray = GetServerData($result);
PrintServerTable($ServerArray);
break;
case "Desktop";
break;
case "Laptop";
break;
}
?>
</div>
</div>
</div>
<div class="clear"></div>
<div id="footer" align="center">
<p> </p>
</div>
</div>
<div id="tagline">
Wagman Construction - Bridging Generations since 1902
</div>
</body>
</html>
감사를 표시하는 HTML에 webbidave의 솔루션과 동일합니다. id가 데이터베이스의 어떤 것과도 일치하지 않지만 $ id가 null 인 경우 전체 페이지가로드되지 않도록하지는 않습니다. –
이것들 앞에'if (empty ($ _ GET [ 'id']))'를 넣을 수 있습니다. – webbiedave