页面是这样的:
名称 所用媒体 用户名  频道名称 状态 操作 
我要把数据库里的信息这样分页显示出来

解决方案 »

  1.   

    <?
    if(!isset($current_page)) $current_page = 1;
    $page_size = 10; //每页显示的记录数
    $begin_page = ($current_page - 1) * $page_size;  
    $resutl = mysql_query("select count(*) from dbtable");
    $record_num = mysql_num_rows($result);
    $total_pages = ceil($record_num / $page_size); //总页数
    $result = mysql_query("select * from dbtable limit $begin_page,$page_size");echo "<table>";
    while($rows=mysql_fetch_array($result)){
       echo "<tr><td>".$rows[名称]."  ".$rows[所用媒体]." ".$rows[用户名]." " .$rows[频道名称]." ".$rows[状态]." ".$rows[操作]."</td></tr>"
    }
    echo "</table>";$up_page = $current_page-1;
    $next_page = $current_page+1;
    if($current_page!=1)
       echo "<a href=".$PHP_SELF."?current_page=1>首页</a>";
    if($current_page>1)
       echo "<a href=".$PHP_SELF."?current_page=".$up_page.">上一页</a>";
    if($current_page<$total_pages)
       echo "<a href=".$PHP_SELF."?current_page=".$next_page.">下一页</a>";
    if($current_page != $total_pages)
       echo "<a href=".$PHP_SELF."?current_page=".$total_pages.">末页</a>";
    ?>