Pagination $ _POST在一个页面上加载?

时间:2015-12-10 07:14:34

标签: php pagination

我的问题是让分页正常工作。

由于我有一个$ page = $ POST _ [" zain"]用于接收记录,因此分页存在问题,它只显示第一页的结果。  

这是我的代码



<

         <!DOCTYPE html>
    <html>
    <head>


    </head>
    <body>

    <form action="zain.php" method="post">
    Topic: <input type="text" name="topic"><br />
    <br />
    Name: <input type="text" name="name"><br /><br />
    Attendance: <input type="text" name="attendance"><br />
    <br />
    <input type="reset" name="reset">
    <input type="submit" id = "go" name="submit" value="Go">
    </form>

    <?php

    $user = 'root';
    $password = 'zz224466';
    $db = 'Zain';

    // Create connection
    $conn = mysqli_connect('localhost', $user, $password, $db);

    // Check connection
    if (!$conn) {
        die("Connection failed: " . mysqli_connect_error());
    }
    echo "";

        mysqli_select_db($conn, "zain");
        //$sql = "CREATE TABLE Lectures(Topic varchar(20), Name varchar(20), Attendence int)";
    $sqli = "INSERT INTO lectures(Topic , Name , Attendence) VALUES('$_POST[topic]','$_POST[name]','$_POST[attendance]')";
        mysqli_query($conn, $sqli);


    ////////////////////////// For print DATABASE on the screen using PAGINATION ////////////////////////////////////////

            mysqli_select_db($conn, "zain");
            if(isset($_GET['page'])){
            if($page=="" || $page=="1")
            {
                $page1 = 0;
            }
    else
    {
        $page1 = ($page*5)-5;
    }

}                 $ dataBase =&#34; SELECT * FROM讲座限制$ page1,5&#34 ;;

            $print = mysqli_query($conn, $dataBase);


            while ($record = mysqli_fetch_array($print))
            {
                echo $record['Topic'];
                echo "</br>";
            }



    $selectDatabase = "SELECT * FROM lectures";
     $res1 = mysqli_query($conn, $selectDatabase);
    $countRow = mysqli_num_rows($res1);
    $a = $countRow/5;
    $a = ceil($a);
    echo "<br>" . $a;
    echo "</br> </br>";
    for($b=1; $b<=$a; $b++)
    {
        ?><a href ="zain.php?page=<?php echo $b; ?>" style="text-decoration: none"><?php echo $b . " ";?></a><?php
    }
    mysqli_close($conn);
    ?>



    </body>
    </html>

1 个答案:

答案 0 :(得分:1)

位于页面顶部。

$zain

然后将所有其他for($b=1; $b<=$a; $b++) { ?><a href ="zain.php?page=<?php echo $b; ?>&zain=<?php echo $zain;?>" style="text-decoration: none"><?php echo $b . " ";?></a><?php } 替换为.award { vertical-align:top; }

在链接部分

<h:dataTable value="#{bookController.books}" var="b">