如何替换get参数?

我有一个页面列出数据库中的文章。当用户单击标签时,他们将被带到 blogsbycategory.php 页面。该页面从 url 中获取 tag 参数,并返回所有具有该标签的博客。在此页面的右侧有一个标签列表。如何更改 GET,以便当用户单击列表中的标签时,url 参数将更新,并且他们可以查看该所选标签的所有博客。


http://example.com/articles/blogsbycategory.php?tag=People%20management



    <?php 

          $tag = $_GET["tag"];

        

    

        $sql = "select * from blogs where tag = '$tag' " ;

        

        $rs = mysqli_query($connect, $sql);

        //get row

        $fetchRow = mysqli_fetch_assoc($rs);

    ?> 


    


  <h3>Tags</h3>

                 <?php 

  while($row = mysqli_fetch_array($result))

  {

      echo '<ul style="list-style: none;">';

   echo '<li>' .$row["tagName"]. '</li><hr />';

   echo '</ul>';

  }

  ?>


慕沐林林
浏览 109回答 2
2回答

慕村9548890

像这样的东西:<h3>Tags</h3>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<?php&nbsp;&nbsp; while($row = mysqli_fetch_array($result))&nbsp; {&nbsp; &nbsp; &nbsp; echo '<ul style="list-style: none;">';&nbsp; &nbsp;echo '<li><a href="http://example.com/articles/blogsbycategory.php?tag=' .$row["tagName"]. '">' . $row["tagName"] . '</a></li><hr />';&nbsp; &nbsp;echo '</ul>';&nbsp; }&nbsp; ?>使用 jQuery 是这样的:<h3>Tags</h3>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<?php&nbsp;&nbsp; &nbsp; &nbsp; while($row = mysqli_fetch_array($result))&nbsp; &nbsp; &nbsp; {&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; echo '<ul style="list-style: none;">';&nbsp; &nbsp; &nbsp; &nbsp;echo '<li onclick="$('#articleContainer').load(' . $row["tagName"] . ')">' . $row["tagName"] . '</li><hr />';&nbsp; &nbsp; &nbsp; &nbsp;echo '</ul>';&nbsp; &nbsp; &nbsp; }&nbsp; &nbsp; &nbsp; ?><div id="art" style="width: 600px; height: 800px; border: 1px solid grey;"></div>

弑天下

将它们列为链接<h3>Tags</h3><ul>&nbsp; <?php while($row = mysqli_fetch_array($result))&nbsp; { ?>&nbsp; &nbsp; <li><a href="/articles/blogsbycategory.php?tag=<?php echo urlencode($row["tagName"]); ?>"><?php echo htmlspecialchars($row["tagName"]); ?></a></li>&nbsp; <?php } ?></ul>在 SQL 语句中使用数据之前,请先引用这些数据。
打开App,查看更多内容
随时随地看视频慕课网APP