我用php和mysql创建了一个搜索功能,但它只搜索一个单词?我该如何让它搜索一个短语

时间:2013-09-16 08:25:19

标签: php html mysql

我创建了一个搜索功能,但只能通过输入一个关键字来实现。如何让某人输入短语并显示结果?在那一刻我必须使用_并告诉客户使用_而不是空间。

    <div class="post">
    <h1 class="title">Search Results for: <?php echo $_POST['keywords']; ?></h1>
    <table style="width: 100%">
    <tr>
            <td></td>
        </tr>

    <?php
    $searchterm = $_POST['keywords'];

    include 'db.inc.php';
    $query = mysql_query("SELECT * FROM search WHERE keywords like '%$searchterm%'");
    while($row = mysql_fetch_array($query))
    {
    ?>
        <tr>
            <td style="font-size:x-large"><a href="./<?php echo $row['link']; ?>">
            <?php echo $row['title']; ?> </a></td>
        </tr>
        <tr>
            <td><?php echo $row['description']; ?></td>
        </tr>
        <tr>
        <tr>
        </tr>


    <?php
    }
    ?>

    </table>
    </div>
    <div class="post">
    </div>
</div>

0 个答案:

没有答案