简单的分类页原理

 

<?php



//分页操作
echo "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />";
mysql_connect($db_host,$db_user,$db_pass);
mysql_query('set names utf8;');
mysql_select_db($db_name);
$dbuse = $db_name.".".$prefix;                    //数据库名与表前缀 ecshop.ecs_
$page_count = 100;                                //记录总数
$page_size = 5;                                    //每页显示记录数
$page = intval($page_count / $page_size);        //分类总页数

for ($i=0; $i <= $page; $i++) {                 //分页数  数组
    $page_array[$i] = $i ;
}

//$page_first = ($page_array[$i] - 1) * $page_size ;    起始数

$page_first = 10;                                //起始数 案例显示固定数


$sql_lr3 = "SELECT goods_id,goods_name FROM ".$dbuse."goods limit ".$page_first.",".$page_size.";";
$query_lr3 = mysql_query($sql_lr3);



echo <<<END

    <table style="margin-left:50px;width:80%;float:left;">
        <tr>
            <td>id</td>
            <td>name</td>
        </tr>
END;
        while ($number_lr3 = mysql_fetch_array($query_lr3)) {
            echo "<tr><td>".$number_lr3['goods_id']."</td><td>".$number_lr3['goods_name']."</td></tr>";
        }

echo "</table>";






?>

 

posted @ 2014-09-11 14:02  龙昊雪  阅读(215)  评论(0编辑  收藏  举报