一个仓库管理系统的web代码
时间: 2024-05-16 11:16:16 浏览: 6
以下是一个简单的仓库管理系统的Web代码示例:
```html
<!DOCTYPE html>
<html>
<head>
<title>仓库管理系统</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>
<h1>仓库管理系统</h1>
<form action="search.php" method="get">
<label for="search">搜索:</label>
<input type="text" id="search" name="search">
<button type="submit">搜索</button>
</form>
<hr>
<table>
<tr>
<th>ID</th>
<th>名称</th>
<th>数量</th>
<th>操作</th>
</tr>
<?php
// 连接数据库
$conn = mysqli_connect('localhost', 'root', '123456', 'warehouse');
if (!$conn) {
die('连接数据库失败:' . mysqli_connect_error());
}
// 查询数据
$sql = "SELECT * FROM goods";
if (isset($_GET['search'])) {
$search = mysqli_real_escape_string($conn, $_GET['search']);
$sql = "SELECT * FROM goods WHERE name LIKE '%$search%'";
}
$result = mysqli_query($conn, $sql);
// 输出数据
while ($row = mysqli_fetch_assoc($result)) {
echo "<tr>";
echo "<td>" . $row['id'] . "</td>";
echo "<td>" . $row['name'] . "</td>";
echo "<td>" . $row['quantity'] . "</td>";
echo "<td><a href=\"edit.php?id=" . $row['id'] . "\">编辑</a> <a href=\"delete.php?id=" . $row['id'] . "\">删除</a></td>";
echo "</tr>";
}
// 关闭连接
mysqli_close($conn);
?>
</table>
<hr>
<a href="add.php">添加商品</a>
</body>
</html>
```
这段代码使用了HTML和PHP语言,实现了以下功能:
- 显示仓库管理系统的标题和搜索表单
- 显示所有商品的表格,并提供编辑和删除操作的链接
- 支持根据名称搜索商品
- 提供添加商品的链接
具体实现细节需要结合数据库和服务器环境进行调整。