douna4762 2014-12-04 09:20
浏览 52

仅显示与主题匹配的内容

How can i show the only content that match the topic?
This code will show all the 'topic' and the 'content'
please help me

this is buzz(like a forum)

    <thead>
    <tr align="center">
        <th>Topic</th>
    </tr>
   </thead>

   <tbody>
    <tr align="center">
        <?php

            $sql = "SELECT buzz_topic FROM buzz";
            $result = $con->query($sql);

                while($row = mysqli_fetch_assoc($result)) {
                    echo"<tr>
                    <td><a href='buzzContent.php'>{$row['buzz_topic']}</a></td>
                    </tr>";
                }
            ?>
    </tr>

    <td><input type="button" value="Add Topic" onClick="document.location.href='addBuzz.php'"></td>

  </tbody>
  </table>

   </form>

this is to add the topic and detail into the buzz database

            <tr>
                <td>Student ID</td>
                <td> 
                    <textarea rows="1" cols="50" type='text' name='student_ID' id='student_ID'></textarea> 
                </td>
            </tr>

            <tr>
                <td>Topic</td>
                <td>
                    <textarea rows="1" cols="50" type='text' name='buzz_topic' id='buzz_topic'></textarea>
                </td>
            </tr>

            <tr>
                <td>Content</td>
                <td>
                      <textarea rows="5" cols="50" type='text' name='buzz_content' id='buzz_content'></textarea>
                </td>
            </tr>

        </table>

            <td><input type="submit" value="Submit" ></td>
            <td><input type="button" onClick="history.go(0)" value="Cancel"></td>

        </form>

this is to show the content of buzz that people are click, but it will show all the content and topic, how can i solve it?

    <h1>
        <?php
            $sql = "SELECT buzz_topic FROM buzz";
            $result = $con->query($sql);

            while($row = mysqli_fetch_assoc($result)) {
            echo $row['buzz_topic'];
            }
        ?>
    </h1>

    <p>
        <?php   

        $sql = "SELECT buzz_content FROM buzz";
        $result = $con->query($sql);

        while($row = mysqli_fetch_assoc($result)) {
        echo $row['buzz_content'];
        }
        ?>
    </p>

    <input type="button" onClick="document.location.href='buzz.php'" value="Back">

    </form>
  • 写回答

2条回答 默认 最新

  • doufeng5059 2014-12-04 09:57
    关注

    Your SQL statement needs a LIKE statement

    SELECT buzz_content FROM buzz WHERE buzz_content LIKE '%searchterm%' 
    
    评论

报告相同问题?

悬赏问题

  • ¥15 微信会员卡接入微信支付商户号收款
  • ¥15 如何获取烟草零售终端数据
  • ¥15 数学建模招标中位数问题
  • ¥15 phython路径名过长报错 不知道什么问题
  • ¥15 深度学习中模型转换该怎么实现
  • ¥15 HLs设计手写数字识别程序编译通不过
  • ¥15 Stata外部命令安装问题求帮助!
  • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
  • ¥15 TYPCE母转母,插入认方向
  • ¥15 如何用python向钉钉机器人发送可以放大的图片?