国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

PHP ?? ?? ?? ??? ?? ?? ??? ??

?? ???? ?? ?? ?? ??? ?? ???????, ?? ????? ?? ?? ??? ??? ??? ??? ?????! ??? ??? ??? ??? ????? ?????????!

?? PHP ?? page.php? ????. ? ??? ??? ?? ??? ?? ??? ????!

? ?? ??: ???? ??????? ?????!

// 顯示所有的錯(cuò)誤
error_reporting(E_ALL & ~E_NOTICE  );
// 連接mysql數(shù)據(jù)庫
$link = mysqli_connect('localhost','root', 'root');
if (!$link) {
    echo "connect mysql error!";
    exit();
}
// 選中數(shù)據(jù)庫 news為數(shù)據(jù)庫的名字
$db_selected = mysqli_select_db($link, 'news');
if (!$db_selected) {
    echo "<br>selected db error!";
    exit();
}
// 設(shè)置mysql字符集 為 utf8
$link->query("set names utf8");

? ?? ??: ??? ??? ????? ?? ??? ?? ??? ???? ??? ???? ???. ??? ??? SQL ?? ?? ???? ???? ???.

// 查詢新聞表中的數(shù)據(jù)
$sql = "select * from new where 1 "; // 查詢語句
$sql_count =  "select count(*) as amount from new where 1 "; // 統(tǒng)計(jì)總記錄數(shù)
$sql .= "order by id asc";

?? ?? ? ??? ?? ???? ???. :

// 獲取總記錄條數(shù)
$result_amount = mysqli_query($link, $sql_count);
$arr_amount = mysqli_fetch_array(mysqli_query($link, $sql_count), MYSQL_ASSOC);
// 總記錄條數(shù)
$amount = $arr_amount['amount'];

?? ?? ? ??? ?? ? ??? ?? ?????

// 每頁的記錄條數(shù)
$page_size = 4;
// 總頁碼
$max_page = ceil( $amount / $page_size );

???? ?? ?? ????? ??? ?? ??? ?? ????. ? ??? ???? ?? ???, ?? ???, ??? ???? ?????!

// 獲取當(dāng)前頁碼
$page = intval($_GET['page']); // 獲取page值,并轉(zhuǎn)成int
if( $page <= 0 || $page > $max_page){  // 如果page值小于0,或是大于最大頁碼
    $page = 1;
}
// 上一頁
$pre_page = $page -1;
if( $pre_page < 1 ){ // 如果上一頁小于1
    $pre_page = 1;
}

// 下一頁
$next_page = $page + 1;
if( $next_page > $max_page ){ // 如果下一頁大于最大頁碼
    $next_page = $max_page;
}
// 分頁計(jì)算, 計(jì)算分頁的offset
$offset = ($page - 1 ) * $page_size;
$sql .= " limit $offset, $page_size ";

??? ??? ??? ????, ?? ?? ???? ? ??? ??? ?????

<?php
include_once "../common/page.php";
?>

????? ?? ?? ??? ???? ??? ??? ?? ???? ??

<div class="pagelist">
<a href="new_list.php">首頁</a>
<?php
if( $page > 1 ){
    ?>
    <a href="new_list.php?page=<?php echo $pre_page;?>">上一頁</a>
    <?
}
if( $page < $max_page ){
    ?>
    <a href="new_list.php?page=<?php echo $next_page;?>">下一頁</a>
    <?
}
?>
<a href="new_list.php?page=<?php echo $max_page;?>">末頁</a>
/  總頁碼 <font color="red"><?php echo $max_page;?></font>頁 當(dāng)前頁碼 <font color="red"><?php echo $page;?></font>頁
</div>

1741.png

OK! ??? ??? ???????!

??: ????? ??? ???? ?????? ?? ??? ?? ????. ??? ??? ??? ??? ??? ???~

???? ??
||
<?php // 顯示所有的錯(cuò)誤 error_reporting(E_ALL & ~E_NOTICE ); // 連接mysql數(shù)據(jù)庫 $link = mysqli_connect('localhost','root', 'root'); if (!$link) { echo "connect mysql error!"; exit(); } // 選中數(shù)據(jù)庫 news為數(shù)據(jù)庫的名字 $db_selected = mysqli_select_db($link, 'news'); if (!$db_selected) { echo "<br>selected db error!"; exit(); } // 設(shè)置mysql字符集 為 utf8 $link->query("set names utf8"); // 查詢簡(jiǎn)歷表中的用戶信息 $sql = "select * from new where 1 "; // 查詢語句 $sql_count = "select count(*) as amount from new where 1 "; // 統(tǒng)計(jì)總記錄數(shù) $sql .= "order by id asc"; // 獲取總記錄條數(shù) $result_amount = mysqli_query($link, $sql_count); $arr_amount = mysqli_fetch_array(mysqli_query($link, $sql_count), MYSQL_ASSOC); // 總記錄條數(shù) $amount = $arr_amount['amount']; // 每頁的記錄條數(shù) $page_size = 4; // 總頁碼 $max_page = ceil( $amount / $page_size ); // 獲取當(dāng)前頁碼 $page = intval($_GET['page']); // 獲取page值,并轉(zhuǎn)成int if( $page <= 0 || $page > $max_page){ // 如果page值小于0,或是大于最大頁碼 $page = 1; } // 上一頁 $pre_page = $page -1; if( $pre_page < 1 ){ // 如果上一頁小于1 $pre_page = 1; } // 下一頁 $next_page = $page + 1; if( $next_page > $max_page ){ // 如果下一頁大于最大頁碼 $next_page = $max_page; } // 分頁計(jì)算, 計(jì)算分頁的offset $offset = ($page - 1 ) * $page_size; $sql .= " limit $offset, $page_size "; ?>