搜索多个类别的产品

w8biq8rn  于 2021-06-15  发布在  Mysql
关注(0)|答案(49)|浏览(666)

我有这个搜索功能与类别,当你点击这个类别,你将在该类别内搜索,但我想使它,使我能够在多个类别内搜索关键字。这是我的表格:

<form method="get" action="zoek.php">
            <input type="text" name="producttitle" placeholder="Productnaam">
            <input type="hidden" name="prodgroup" value="<?= (isset($_GET['prodgroup'])) ? $_GET['prodgroup'] : '' ?>">
            <input type=submit class="btn btn-primary" value="Zoek...">
        </form>

这是您单击类别并搜索单词的代码

<?php
    if (isset($_GET['prodgroup']) && $_GET['prodgroup'] != "" && isset($_GET['producttitle']) && $_GET['producttitle'] != "") {
        $category = $_GET['prodgroup'];
        $prodtit = $_GET['producttitle'];

        $query = $readconn->prepare("
SELECT S.StockItemID, S.StockItemName, S.Photo, S.UnitPrice, S.Photo, S.Brand
FROM stockitems S JOIN stockitemstockgroups SISG ON S.StockItemID = SISG.StockItemID
JOIN stockgroups SG ON SISG.StockGroupID = SG.StockGroupID
WHERE SG.StockGroupID = '" . $category . "'
AND S.StockItemName LIKE '%" . $prodtit . "%'
");

以下是带有id的类别: `.

相关问题