2017-06-04 08:05

如何在使用分页时使用PHP中的Session传输GET / POST数据


This is my code:

$tag1 = $_GET['tag1'];
$tag2 = $_GET['tag2'];

$stmt = $conn->prepare("SELECT name FROM info WHERE tag1='$tag1' OR tag2='$tag2' LIMIT $limit OFFSET $start");

// Pagination
while ($pagenumber != $totalpages) 

    echo "<a href='?page=".$pagenumber."'>".$pagenumber."</a>";  

Everything is working fine, but when i go to any other page, I get this 2 errors:

Notice: Undefined index: tag1

Notice: Undefined index: tag2
  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答


  • drls2738 drls2738 4年前

    you can pass your get value into your link, be sure that vars are set before

    try this please

    echo "<a href='?page=".$pagenumber."&tag1=".$tag1."&tag2=".$tag2."'>".$pagenumber."</a>";
    点赞 评论 复制链接分享