您好我在我的index.php上收到此消息
注意:使用未定义的常量id - 假设' id'在第70行的C:\ xampp \ htdocs \ practice \ index.php
注意:使用未定义的常量部门 - 假定的部门'在第71行的C:\ xampp \ htdocs \ practice \ index.php
注意:使用未定义的常量保管人 - 假设保管人'在第72行的C:\ xampp \ htdocs \ practice \ index.php
注意:使用未定义的常量位置 - 假设'位置'在第73行的C:\ xampp \ htdocs \ practice \ index.php
注意:使用未定义的常量品牌 - 假定品牌'在第74行的C:\ xampp \ htdocs \ practice \ index.php
注意:使用未定义的常量模型 - 假设'模型'在第75行的C:\ xampp \ htdocs \ practice \ index.php
注意:使用未定义的常量硬件 - 假设' hardwaresn'在第76行的C:\ xampp \ htdocs \ practice \ index.php
注意:使用未定义的常量硬盘 - 假设' hardisk'在第77行的C:\ xampp \ htdocs \ practice \ index.php
注意:使用未定义的常量处理器 - 假定处理器'在第78行的C:\ xampp \ htdocs \ practice \ index.php
注意:使用未定义的常量ram - 假设' ram'在第79行的C:\ xampp \ htdocs \ practice \ index.php
注意:使用未定义的常量监视器 - 假设'监视器'在第80行的C:\ xampp \ htdocs \ practice \ index.php
注意:使用未定义的常量实际值 - 假设' actualos'在第81行的C:\ xampp \ htdocs \ practice \ index.php
注意:使用未定义的常量msoffice - 假设' msoffice'在第82行的C:\ xampp \ htdocs \ practice \ index.php
注意:使用未定义的常量供应商 - 假设供应商'在第83行的C:\ xampp \ htdocs \ practice \ index.php
注意:使用未定义的常量invoicenumber - 假设' invoicenumber'在第84行的C:\ xampp \ htdocs \ practice \ index.php
注意:使用未定义的常数购买者 - 假设'已购买'在第85行的C:\ xampp \ htdocs \ practice \ index.php
注意:使用未定义的恒定保修 - 假设保修'在第86行的C:\ xampp \ htdocs \ practice \ index.php
Id Deparment Custodian Location Brand Model Hardware SN Case/Monitor HardDisk Processor Ram Monitor Actual OS MS Office Supplier Invoice No. Purchase Date Warranty Line to Edit Line to Delete
1 Motor Ibrahim Abu Lebda 1st Floor Lenovo MTM 10A9-003CAX PC08KULS/ CNC137R2N1 1TB Intel Core i7 8GB 20'' LED HP Win 7 Pro 2013 0000-00-00 Out Of Warranty Edit Delete
Add New Record
这是我的代码,请帮助我确定什么不是声明。
<html>
<head>
<title>IT Equipment Inventory System</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
</head>
<body>
<h1><center>IT Equipment Inventory System</center></h1>
<?php
echo "<marquee>" . "Today is " . date("m/d/Y") . "</marquee>";
echo "<marquee>" . "Today is " . date("l") . "</marquee>";
?>
<?php
// connect to the database
include 'db_connection.php';
$conn = OpenCon();
//echo "Connected Successfully";
// get the records from the database
$result = mysqli_query($conn, "SELECT * FROM tb1");
CloseCon($conn);
// display records in a table
echo "<p><b>View All</b> | <a href='view-paginated.php?page=1'>View Paginated</a></p>";
echo "<table border='1' cellpadding='10'>";
// set table headers
echo "<tr>
<th>Id</th>
<th>Deparment</th>
<th>Custodian</th>
<th>Location</th>
<th>Brand</th>
<th>Model</th>
<th>Hardware SN Case/Monitor</th>
<th>HardDisk</th>
<th>Processor</th>
<th>Ram</th>
<th>Monitor</th>
<th>Actual OS</th>
<th>MS Office</th>
<th>Supplier</th>
<th>Invoice No.</th>
<th>Purchase Date</th>
<th>Warranty</th>
<th>Line to Edit</th>
<th>Line to Delete</th>
</tr>";
while($row = mysqli_fetch_array( $result )) {
// set up a row for each record
echo '<tr>';
echo '<td>' . $row[id] . '</td>';
echo '<td>' . $row[department] . '</td>';
echo '<td>' . $row[custodian] . '</td>';
echo '<td>' . $row[location] . '</td>';
echo '<td>' . $row[brand] . '</td>';
echo '<td>' . $row[model] . '</td>';
echo '<td>' . $row[hardwaresn] . '</td>';
echo '<td>' . $row[hardisk] . '</td>';
echo '<td>' . $row[processor] . '</td>';
echo '<td>' . $row[ram] . '</td>';
echo '<td>' . $row[monitor] . '</td>';
echo '<td>' . $row[actualos] . '</td>';
echo '<td>' . $row[msoffice] . '</td>';
echo '<td>' . $row[supplier] . '</td>';
echo '<td>' . $row[invoicenumber] . '</td>';
echo '<td>' . $row[purchasedate] . '</td>';
echo '<td>' . $row[warranty] . '</td>';
echo '<td><a href="edit.php?id=' . $row['id'] . '">Edit</a></td>';
echo '<td><a href="delete.php?id=' . $row['id'] . '">Delete</a></td>';
echo '</tr>';
}
echo "</table>";
?>
<a href="New.php">Add New Record</a>
</body>
</html>
答案 0 :(得分:4)
您忘记在while()
代码中的索引名称周围添加引号。
例如: - $row[id]
需要$row['id']
如下所示: -
while($row = mysqli_fetch_assoc( $result )) {
// set up a row for each record
echo '<tr>';
echo '<td>' . $row['id'] . '</td>';
echo '<td>' . $row['department'] . '</td>';
echo '<td>' . $row['custodian'] . '</td>';
echo '<td>' . $row['location'] . '</td>';
echo '<td>' . $row['brand'] . '</td>';
echo '<td>' . $row['model'] . '</td>';
echo '<td>' . $row['hardwaresn'] . '</td>';
echo '<td>' . $row['hardisk'] . '</td>';
echo '<td>' . $row['processor'] . '</td>';
echo '<td>' . $row['ram'] . '</td>';
echo '<td>' . $row['monitor'] . '</td>';
echo '<td>' . $row['actualos'] . '</td>';
echo '<td>' . $row['msoffice'] . '</td>';
echo '<td>' . $row['supplier'] . '</td>';
echo '<td>' . $row['invoicenumber'] . '</td>';
echo '<td>' . $row['purchasedate'] . '</td>';
echo '<td>' . $row['warranty'] . '</td>';
echo '<td><a href="edit.php?id=' . $row['id'] . '">Edit</a></td>';
echo '<td><a href="delete.php?id=' . $row['id'] . '">Delete</a></td>';
echo '</tr>';
}
注意: - 使用mysqli_fetch_assoc()
代替mysqli_fetch_array
,因此只会出现关联数组。