Php 表的分页是';t添加?偏移量
我有一张桌子要处理。试图让它从Php 表的分页是';t添加?偏移量,php,html,pagination,Php,Html,Pagination,我有一张桌子要处理。试图让它从$json变量中获取所有用户,然后添加?offset=25 但是,当我单击它,URL被更改时,里面的实际数据不会移动 <?PHP $offset = 0; //Stream Follow Json $json = json_decode(file_get_contents("https://api.twitch.tv/kraken/channels/greatbritishbg/follows?limit=25&offset". $o
$json
变量中获取所有用户,然后添加?offset=25
但是,当我单击它,URL被更改时,里面的实际数据不会移动
<?PHP
$offset = 0;
//Stream Follow Json
$json = json_decode(file_get_contents("https://api.twitch.tv/kraken/channels/greatbritishbg/follows?limit=25&offset". $offset));
$i = 0;
//check if the starting row variable was passed in the URL or not
//this part goes after the checking of the $_GET var
$num= 25;
// Creating an object
$json->follows;
if($num>0)
{
echo "<table border=2>";
echo "<tr><td>Username</td><td>Follow Date</td></tr>";
foreach($json->follows as $follow) {
$i++;
echo "<tr>";
echo "<td><a href='" . $follow->user->_links->self . "'>" . $follow->user->name . " (".$i. ")</td>";
echo "<td>" . $follow->user->created_at . "</td>";
echo "</tr>";
}//for
echo"</table>";
}
//now this is the link..
echo '<a href="'.$_SERVER['PHP_SELF'].'?limit=25&offset='.($offset+25).'">Next</a>';
$prev = $offset - 25;
//only print a "Previous" link if a "Next" was clicked
if ($prev >= 0)
echo '<a href="'.$_SERVER['PHP_SELF'].'?limit=25&offset='.$prev.'">Previous</a>';
?>
在您的代码中
limit=25". $offset
变成
limit=250
你需要
limit=25&offset=". $offset
不知道这会如何运作。。。它是如何变成250的。。。此外,当我手动键入限制和偏移量时,它不会更改数据值。$offset
设置为0
,因此您要说的是加入limit=25
和$offset
,这将成为limit=250
。在我上面的示例中,您正在添加&offset=
,因此它将$offset
变量连接在一起,使其成为&offset=0
。有意义吗?啊,我现在明白了:)我更新了上面的代码,它仍然没有更新数据。我假设这是因为我的下一个和上一个都是$\u服务器,没有更改JSON。我将如何更改JSON url?