123456789101112131415161718192021222324 |
- <?php
- include "conn.php";
- checkLogin("信息管理");
- $str = textEncode($_GET['str'] ?? '');
- $sql = "SELECT p.id, p.ProductImg, p.ProductName, p.unit, p.category_id, pc.name as categoryName
- FROM products p
- LEFT JOIN product_categories pc ON p.category_id = pc.id
- WHERE p.productName LIKE '%" . $str . "%'";
- $rs = $conn->query($sql);
- while ($row = $rs->fetch_assoc()) {
- $categoryDisplay = !empty($row['categoryName']) ? ' <span style="color:#888;font-size:12px;">['.$row['categoryName'].']</span>' : '';
- ?>
- <li data-id="<?php echo $row['id']; ?>" data-unit="<?php echo $row['unit']; ?>">
- <div class="list-content">
- <div class="pic"><img src="<?php echo $row['ProductImg']; ?>" ></div>
- <div class="name"><?php echo $row['ProductName']; ?><?php echo $categoryDisplay; ?></div>
- </div>
- </li>
- <?php
- }
- ?>
|