从外部链接分页


Pagination from an external link

好吧,我不知道如何做到这一点,我有一个MySQL查询的分页系统,但我陷入了一个思考的过程中,我将如何把一个外部链接结果20(或者即使我做了50)变成每页10个结果的页面?

我现在使用的代码如下:

error_reporting(E_ALL);
$feedURL = 'http://gdata.youtube.com/feeds/api/users/sentuamsg/uploads?max-results=20';
$sxml = simplexml_load_file($feedURL);
$i=0;
foreach ($sxml->entry as $entry) {
  $media = $entry->children('media', true);
  $watch = (string)$media->group->player->attributes()->url;
  $thumbnail = (string)$media->group->thumbnail[0]->attributes()->url;
parse_str( parse_url( $watch, PHP_URL_QUERY ), $my_array_of_vars );
echo "presentation of the result goes here";
$i++; if($i==5) { 
$i=0; 
 } 
}

有人知道我怎么做这个吗?

Youtube Gdata API有一个名为"start-index"的变量。您可以创建一个基于php的函数来检测当前页面并将其放入变量+ 1中。

会像…

当前页面…

http://gdata.youtube.com/feeds/api/users/sentuamsg/uploads?max-results=20&起始索引= 1

第二页…

http://gdata.youtube.com/feeds/api/users/sentuamsg/uploads?max-results=20&起始索引= 21

这就是逻辑。每页,加20成值。例如,如果你想显示20个结果