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

??? ?? ???

?? ??????? ?? ??? ???, ??? ??, ???? ? ?????? ?????.
??? ???? ???, ?????? ??? ?? ??? ?????, ??? ?? ????? ?? ?????? ??? ??? ?? ????.

?? ?? ????? ??????? ???? ???. ?? ??? ??? ????, ??? ????, ?? ??? ???? ??? ?? ?? ??????. ??? ??? ??? ????? ?? ??? ?? ????.

?? ??? ??? ?? ??? ???? ??? ??? ? ????. ?? ??? ??? ????.

QQ截圖20161010101506.png

??? ?? ?? config.php? ?? ? ????. ??? ???? ?? ?? ??? ?????. ??? ??? ????.

<?php
//數(shù)據(jù)庫(kù)服務(wù)器
define('DB_HOST', 'localhost');
//數(shù)據(jù)庫(kù)用戶名
define('DB_USER', 'root');
//數(shù)據(jù)庫(kù)密碼
define('DB_PWD', 123456789);
//庫(kù)名
define('DB_NAME', 'book');
//字符集
define('DB_CHARSET', 'utf8');
?>

??? ??????? ???? ? ???? ???? ???. Connection.php ??. ??? ??? ????.

<?php
include 'config.php';
$conn = mysqli_connect(DB_HOST, DB_USER, DB_PWD, DB_NAME);
if (mysqli_errno($conn)) {
    mysqli_error($conn);
    exit;
}
mysqli_set_charset($conn, DB_CHARSET);

?? ? ??? Connection.php ??? ?? ???? ?????? ??? ??? ? ????.

include 'connection.php';

?? ????? ?? ?? ? ???? ??? ???. ??? ?? ??? ??? ????.

QQ截圖20161010101814.png

????? ??? ?? ?? ??? ????? ???.

QQ截圖20161010101852.png

QQ截圖20161010101858.png

??? ?? ?? ? URL ???? ?? ??? ?? ?? ???? ??? ?? ??? ?????. page.php? ??? ?? ?? ??? ???? ?? ???? ??? ??? ? ????. URL ?? ???? ??? ??? ????.

QQ截圖20161010101933.png

?? ???? ? ? ?? ??? ???(offset)? ??( num) ??? ?? ??.

limit offset , num

QQ截圖20161010101943.png

? ???? 5?? ??? ????? ?????. ??? ??? ???? ???? ??? ??? ????.

??? ?? (n-1)*5
num? ??? 5

? ?? ????? ?????. code:

1. ???? ??? ???? ??

? ??

??? ???? count(id)? ???? ? ?? $count? ????.

$count_sql = 'select count(id) as c from user';
$result = mysqli_query($conn, $count_sql);
$data = mysqli_fetch_assoc($result);
//得到總的用戶數(shù)
$count = $data['c'];

?? ???

page.php ???? ?? ???? URL? http://www.phpxy.com/page.php??, ???? ?? ?page? ?????. =1 ??? ?? ??.

??? ??? ?? ??? ???? ???? ?? ?? ??? ?? ?? $page? ???? ???.

???? ??? ???? ??? ?? ???? ?? ?? ??((int) $_GET['page'])? ?????.

? ?? ?? ??:

$page = isset($_GET['page']) ? (int) $_GET['page'] : 1;

? ?? ?? ??

if (isset($_GET['page'])) {
    $page = (int) $_GET['page'];
} else {
    $page = 1;
}

??? ???

? ???? ???? ???. ?? ???? ??? ????. ????? 5.6?? ?? ??? ???? ???. ?? 6??? ???.

???? 20.3???? ??? ??? ?? ???? ???? ???. ??? ??? ?? 21? ?????.

? ??? ?? ? ???? ???? ??? ?? ?? ??? ? ??? ?? ????.

//???? ????? ?

$num = 5;
$total = ceil($count / $num);

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

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

? ?? ???? ??? ???? ???? ?? ? ???? ???? ????.

??? ??? ??? ??? ???? ???. ??? ??? ?? ? ?? ????? 1? ?? ?? ? ?? ???? ????.
??? ???? ??? ???? ??? ???? ??? ????? ?????.

if ($page <= 1) {
    $page = 1;
} 
if ($page >= $total) {
    $page = $total;
}

2. SQL?

?? ???? ??? SQL?? ???? num? ?? ? ???? ?? ??? ???? ???? ?????.

?? ?? ??? ??????.

$num = 5;
$offset = ($page - 1) * $num;

SQL ?? $num ? $offset? ??????.

$sql = "select id,username,createtime,createip from user order by id desc limit $offset , $num";

Control URI? ??? ?

echo '<tr>
    <td colspan="5">
    <a href="page.php?page=1">首頁(yè)</a>
    <a href="page.php?page=' . ($page - 1) . '">上一頁(yè)</a>
    <a href="page.php?page=' . ($page + 1) . '">下一頁(yè)</a>
    <a href="page.php?page=' . $total . '">尾頁(yè)</a>
    當(dāng)前是第 ' . $page . '頁(yè)  共' . $total . '頁(yè)
    </td>
    </tr>';

??? ?? ????? ???? ?? ??? ????. ??? ??? ????.

<?php
include 'connection.php';
$count_sql = 'select count(id) as c from user';
$result = mysqli_query($conn, $count_sql); 
$data = mysqli_fetch_assoc($result);
//得到總的用戶數(shù)
$count = $data['c'];
$page = isset($_GET['page']) ? (int) $_GET['page'] : 1;
/*
if (isset($_GET['page'])) {
    $page = (int) $_GET['page'];
} else {
    $page = 1;
}
 */
//每頁(yè)顯示數(shù)
$num = 5;
//得到總頁(yè)數(shù)
$total = ceil($count / $num);
if ($page <= 1) {
    $page = 1;
}
if ($page >= $total) {
    $page = $total;
}
$offset = ($page - 1) * $num;
$sql = "select id,username,createtime,createip from user order by id desc limit $offset , $num";
$result = mysqli_query($conn, $sql);
if ($result && mysqli_num_rows($result)) {
    //存在數(shù)據(jù)則循環(huán)將數(shù)據(jù)顯示出來(lái)
    echo '<table width="800" border="1">';
    while ($row = mysqli_fetch_assoc($result)) {
        echo '<tr>';
        echo '<td>' . $row['username'] . '</td>';
        echo '<td>' . date('Y-m-d H:i:s', $row['createtime']) . '</td>';
        echo '<td>' . long2ip($row['createip']) . '</td>';
        echo '<td><a href="edit.php?id=' . $row['id'] . '">編輯用戶</a></td>';
        echo '<td><a href="delete.php?id=' . $row['id'] . '">刪除用戶</a></td>';
        echo '</tr>';
    }
    echo '<tr><td colspan="5"><a href="page.php?page=1">首頁(yè)</a>  <a href="page.php?page=' . ($page - 1) . '">上一頁(yè)</a>   <a href="page.php?page=' . ($page + 1) . '">下一頁(yè)</a>  <a href="page.php?page=' . $total . '">尾頁(yè)</a>  當(dāng)前是第 ' . $page . '頁(yè)  共' . $total . '頁(yè) </td></tr>';
    echo '</table>';
} else {
    echo '沒有數(shù)據(jù)';
}
mysqli_close($conn);
?>

??? ??

1. ?? SQL ??? Limit? ???? ?????.

SELECT * FROM table...limit ?? ??, ?? ?? ??(?? ??? 0?? ??)

?:

?? 20? ??? ????: SELECT * FROM table...limit 0, 20
20? ??? ???? 11???? ??: SELECT * FROM table …… Limit 10 , 20

LIMIT n? LIMIT 0,n? ?????.

?? ??, select * from table LIMIT 5; //select * from table LIMIT 0, 5? ???? ?? 5? ?? ?????.

2. ??

?? ??? ??? ??????? ??? ??? ?????? ???? ?? ?????.

???? ??, ?? ?? ????? ???( ???? ?? ?, ?? ??? ?? ?) ???)

?? 10? ???: ??? ?? 0,10?? * ??
11~20?? ???: ??? ?? 10?? * ?? ,10
21???? 30?? ??? :??? ?? 20,10?? * ??

??? ??:

(?? ??? ?? - 1) >

3. $_SERVER["REQUEST_URI"] ??

? ?? ??? ?? ??? ???? $_SERVER? ???? ?? ?? ?? ??? ?? ???? ???.

REQUEST_URI? ??? ??? ??? ??? ?? ?? ??? ?? URI? ???? ????.

?:

?? ???? http://www.test.com/home.php?id=23&cid=22

echo $_SERVER["REQUEST_URI"]

??? ??? ????. : / home.php?id=23&cid=22

4.parse_url() URL ?? ??

parse_url()? ???? ?????. ?? ? ? ??? ?? ??? URL

?

Select * from table limit ($Page- 1) * $PageSize, $PageSize

??:

??
(
[???] => ; http ;????
???????????????????????????????????????????????????????????????????????????????????????????????????????????????[path] => ; /path?????????????????; >

5. ?? ??




? ??? ???? ? ???? ???, ??? ?????? ??????. , ??? ?? ????? ?? ??? ?? ??????.


(1) ??? ??????

??? ??????? bbs?? ??, ??, ?? ??, ???, ??? ?? ??? ???? ????? ??? ???? ????. ??? ??, ??? ??, ??? ??, ??? ?? (2) ?? ???

$ua=parse_url("http://username:password@hostname/path?arg=value#anchor");
 print_r($ua);

(3) ?? ??? ???????

???? ??
||
<?php include 'connection.php'; $count_sql = 'select count(id) as c from user'; $result = mysqli_query($conn, $count_sql); $data = mysqli_fetch_assoc($result); //得到總的用戶數(shù) $count = $data['c']; $page = isset($_GET['page']) ? (int) $_GET['page'] : 1; /* if (isset($_GET['page'])) { $page = (int) $_GET['page']; } else { $page = 1; } */ //每頁(yè)顯示數(shù) $num = 5; //得到總頁(yè)數(shù) $total = ceil($count / $num); if ($page <= 1) { $page = 1; } if ($page >= $total) { $page = $total; } $offset = ($page - 1) * $num; $sql = "select id,username,createtime,createip from user order by id desc limit $offset , $num"; $result = mysqli_query($conn, $sql); if ($result && mysqli_num_rows($result)) { //存在數(shù)據(jù)則循環(huán)將數(shù)據(jù)顯示出來(lái) echo '<table width="800" border="1">'; while ($row = mysqli_fetch_assoc($result)) { echo '<tr>'; echo '<td>' . $row['username'] . '</td>'; echo '<td>' . date('Y-m-d H:i:s', $row['createtime']) . '</td>'; echo '<td>' . long2ip($row['createip']) . '</td>'; echo '<td><a href="edit.php?id=' . $row['id'] . '">編輯用戶</a></td>'; echo '<td><a href="delete.php?id=' . $row['id'] . '">刪除用戶</a></td>'; echo '</tr>'; } echo '<tr><td colspan="5"><a href="page.php?page=1">首頁(yè)</a> <a href="page.php?page=' . ($page - 1) . '">上一頁(yè)</a> <a href="page.php?page=' . ($page + 1) . '">下一頁(yè)</a> <a href="page.php?page=' . $total . '">尾頁(yè)</a> 當(dāng)前是第 ' . $page . '頁(yè) 共' . $total . '頁(yè) </td></tr>'; echo '</table>'; } else { echo '沒有數(shù)據(jù)'; } mysqli_close($conn); ?>