gpt4 book ai didi

php - 带分页的搜索表单

转载 作者:行者123 更新时间:2023-11-30 00:08:59 25 4
gpt4 key购买 nike

我在记录结果的分页方面遇到问题。

我想使用搜索表单显示保存在数据库表中的所有用户,并根据以下脚本对它们进行相应的分页:

http://papermashup.com/easy-php-pagination/

如果我在下面的查询中手动插入性别值,

"SELECT * FROM $tableName WHERE playerSex  = '0' LIMIT $start, $limit";

我可以毫无问题地显示所有女性用户,

如果我通过这样的表单发送值

"SELECT * FROM $tableName WHERE playerSex  ='" . mysql_real_escape_string($_GET['gendre']) ."' 
LIMIT $start, $limit";

仅第一页显示女性用户。单击第 2 页,脚本会显示所有记录(男性和女性),而不是请求的女性记录。

如何解决这个问题?

谢谢

最佳答案

您应该在分页 href 中保留您的性别选项。像这样的东西:

<?php
foreach $key.... //pagination creator loop
if(isset($_GET['gender']))
$href = $key . '&gender=' . $_GET['gender'];
else
$href = $key;
?>

关于php - 带分页的搜索表单,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24244349/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com