php - 如何将 GET 添加到 <a href> 标签?

标签 php html css http

https://imgur.com/a/HUX8Z

如图所示,我有一组类别。我想,当我点击一个类别时,它会按类别重新组织博客文章。为此,我需要在旁边发送一个 GET。但我想不通。

<div class="lx-sidebar-item">
  <div class="lx-sidebar-item-title">
    <h3>Categories</h3>
  </div>
  <div class="lx-sidebar-item-content">
    <div class="lx-links-list">
      <ul>
        <?php $i = 0; while ($i < $numOfRowsCategories){
            echo '<li><a href="">';echo $categories[0]; array_shift($categories); echo'<span>';echo $amount[0]; array_shift($amount);'</span></a></li>';$i++;}
        ?>
      </ul>
      </form>
      <div class="lx-clear-fix"></div>
    </div>
  </div>
</div>

numOfRowsCategories 只是数据库中 cateogires 表的行计数。 $categories 只是来自所有类别数据库的数组。

我试过这个解决方案,它说使用按钮代替 How can I submit a POST form using the <a href="..."> tag?

虽然它在理论上可行,但我不知道如何设置按钮的样式以使其看起来像我当前的页面。

最佳答案

如果 $categories[0] 是 Id。你应该使用

  <ul>
    <?php $i = 0; while ($i < $numOfRowsCategories){
        echo '<li><a href="yourPage.php?categories='.$categories[$i].'">Category N</a></li>';$i++;}
    ?>
  </ul>

这里是 yourPage.php 是将在另一侧获得 $_GET['categories'] 的页面。并且,?categories= 是变量,它将通过 GET 方法发送到 yourPage.php。

关于php - 如何将 GET 添加到 <a href> 标签?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48874817/

相关文章:

javascript - Php 函数订购图片

带有模糊 Angular 的 html 图像标记

html - 为所有子菜单添加固定位置和宽度

php - Zend OPcache 的 "num_cached_keys"统计数据是什么意思?

html - 为什么我的红色边框没有环绕我的文本 div 和侧栏 div

javascript - 当尝试在 JS 中单击时更改 V 形方向时,只有 1 个 V 形发生变化。

python - 如何通过 gmail-api for python 发送 HTML 格式的电子邮件

javascript - 从 json 制作 slider

php - strpos 不在负偏移量上向后搜索

php - 学说 2 : group by field alias (Error: '...' does not point to a Class. )