-1
我正在處理一個簡單的vlog站點項目,我試圖在每個頁面上只顯示20個視頻縮略圖,並且我在索引中編寫了這段代碼以將視頻分割爲多個頁面,然後分頁...問題是它顯示了無限頁面的每頁相同的第一個視頻的縮略圖20次。PHP視頻多個頁面無法正常工作
我真的需要幫助,這代碼
<?php
require_once ('db.php') ;
require_once ('VideosApi.php') ;
$count = mysql_query('SELECT COUNT(id) AS numb FROM videos ORDER BY id');
$array = mysql_fetch_assoc($count);
$number = $array['numb'];
mysql_free_result($count);
$PerPage = 20;
$nbPage = ceil(abs($number/$PerPage));
if(isset($_GET['page']) && $_GET['page'] > 0 && $_GET['page'] <= $nbPage && preg_match('#^[0-9]+$#',$_GET['page'])){ $cPage = $_GET['page']; }
else{ $cPage = 1; }
$Query = mysql_query('SELECT * FROM Videos ORDER BY id LIMIT '.(($cPage-1) * $PerPage).','.$PerPage);
$videos = Videos_Get() ;
if ($videos == Null)
die ('problem');
$vcount = @count ($videos) ;
if ($vcount == 0)
die('no videos') ;
For ($i = 0; $i < $vcount; $i++)
{
$video = $videos [$i];
if ($video->time > 3600)
$duration = gmdate("H:i:s",$video->time);
else
$duration = gmdate("i:s",$video->time);
while($Rows = mysql_fetch_assoc($Query)){
echo ("<div class=\"video\">
<a href=\"video.php?id=$video->id\"><img src=\"$video->img\"></a><span class=\"class-video-name\">$video->name</span>
<div class=\"class-video-footer\">
<span class=\"class-video-duration\">$duration</span>
</div>
</div>") ; }
} ?>
你的代碼是偉大的..它運作良好,也看起來非常專業 我希望有一天我可以編寫就像你..感謝了很多:d – Alex36
如果上面的幫助的代碼,請考慮upvoting並接受它作爲正確答案。 – BenM