zoukankan      html  css  js  c++  java
  • PHP+Mysql分页

    <?php
    $conn = mysql_connect ( "localhost", "root", "root" );
    mysql_select_db ( "test", $conn );
    mysql_query ( "set names 'UTF-8'" );
    
    $showNum = 4;
    if ($_GET ['goPageNum']) {
        $goPageNum = $_GET ['goPageNum'];
        if ($goPageNum <= 0)
            $goPageNum = 1;
    } else {
        $goPageNum = 1;
    }
    
    $nowShowBeginNum = ($goPageNum - 1) * $showNum; // 索引0算第一条数据
    $sel_message = "select * from message limit $nowShowBeginNum,$showNum";
    $que_message = mysql_query ( $sel_message ) or die ( "Invalid query: " . mysql_error () );
    ?>
    
    
    <form action="" method="get">
        <a href="?goPageNum=<?php echo ($goPageNum -1);?>">上一页</a> :<a href="?goPageNum=<?php echo ($goPageNum +1);?>">下一页</a><br/>
    <?php
    while ( $row_message = mysql_fetch_array ( $que_message ) ) {
        echo $row_message ['id'] . " : " . $row_message ['title'] . " : " . $row_message ['content'] . "<br>";
    }
    ?>
    </form>
  • 相关阅读:
    C# Graphics类详解
    c#画直线
    c#画直线
    基础练习 数列特征
    基础练习 数列特征
    基础练习 字母图形
    基础练习 字母图形
    基础练习 字母图形
    基础练习 01字串
    基础练习 01字串
  • 原文地址:https://www.cnblogs.com/dreamhome/p/2394790.html
Copyright © 2011-2022 走看看