您好, 欢迎来到 !    登录 | 注册 | | 设为首页 | 收藏本站

如何获得分页后的价值

如何获得分页后的价值

您的代码中有几个问题。

第一的:

您使用的$_GET变量不正确。您有$_GET{'page'},但您应该使用与$_POST变量相同的方式,如下所示:$_GET['page']

第二:

您正在解释“发布”的概念,并错误地单击了链接。您需要使用下一个和上一个按钮进行的??操作是一个隐藏的表单,其中包含您需要的所有其他变量。例如,最简单的方法无需更改许多其他代码

if( $page > 0 & $left_rec > $rec_limit)
{
    $last = $page - 2;
    // PrevIoUs button form
    echo "<form action='?page=$last' method='POST'>";
    echo "<input type='hidden' name='q' value='" . $_POST['q'] . "' />"; // This will be a field that saves information but won't appear on the page (though a user Could see it if they view source)
    echo "<input type='submit' value='PrevIoUs Records' />";
    echo "</form>";
    echo " | "; // The delimiting character you were using, you'll need to style the input type='submit's to look more like a link if that's what you are going for
    // Next button form
    echo "<form action='?page=$page' method='POST'>";
    echo "<input type='hidden' name='q' value='" . $_POST['q'] . "' />"; // This will be a field that saves information but won't appear on the page (though a user Could see it if they view source)
    echo "<input type='submit' value='Next  Records' />";
    echo "</form>";
}

方法会将您的变量保留在请求中。使用链接实际上会重置$ _POST变量。还有很多其他可能的解决方案,但这是修改示例所需的工作量最少的解决方案。

其他 2022/1/1 18:47:04 有423人围观

撰写回答


你尚未登录,登录后可以

和开发者交流问题的细节

关注并接收问题和回答的更新提醒

参与内容的编辑和改进,让解决方法与时俱进

请先登录

推荐问题


联系我
置顶