我想在底部显示分页,它显示在右侧

时间:2018-11-25 18:07:41

标签: php mysql pagination question2answer

问题是我在网站中使用分页,但是分页实际上显示在页脚上。但是在我的网站上,它显示在页面的右侧。你们能帮我吗?

您可以查看屏幕截图以更好地理解。

enter image description here


这是代码

<table class="table table-bordered">  
<thead>  

<?php

if(isset($_GET['page'])){
    $page = $_GET['page'];
}
else{
    $page = 1;
}
if($page ==''||$page == 1){
    $page1 = 0;
}
else{
    $page1 = ($page*10)-10;
}
$sql = 'select * from divlink ORDER BY Name ASC Limit '.$page1.', 12';
$data = $connect->query($sql);

//print_r($data ->fetch_all());

while($row = mysqli_fetch_array($data)){
    $image  = $row['image'];
    $Name = $row[0];
        $Description = $row[1];
        $Price = $row[2];
        $ExpirtyDate = $row[3];
        $Facebook = $row[4];
        $Twitter = $row[5];
        $Telegram = $row[6];
        $Gmail = $row[7];
        $Youtube = $row[8];
        $Reddit = $row[9];
        $Meduim = $row[10];
        $Myetherwallet = $row[11];
        $neowallet = $row[12];
        $Bitcointalk = $row[13];
        $divicon = $row[14];
        $kyc = $row[15];
         $id = $row['id'];  
    $Rating = $row[17]; 

        //echo "<a href=''><div id='one' class='bordered' width='650px'><img src='{$Name}' class='imgss'/>{$Description}<p align='left'>{$id}</p><p align='right'>{$Price}</p><img src='{$Facebook}'width='20' height='20'><img src='{$Twitter}'  width='20' height='20' align='right'/> <img src='{$Gmail}'  width='20' height='20' align='right'/><img src='{$Youtube}'  width='20' height='20' align='right'/><img src='{$Reddit}'  width='20' height='20' align='right'/><img src='{$Meduim}'  width='20' height='20' align='right'/><img src='{$Myetherwallet}'  width='20' height='20' align='right'/><img src='{$neowallet}'  width='20' height='20' align='right'/><img src='{$Bitcointalk}'  width='20' height='20' align='right'/<img src='{$kyc}'  width='20' height='20' align='right'/>1<div id='circle'></div></a><input type='button' value='Like' name='click' class = 'block'>";
echo "<a href=''><div id='one' class='bordered' width='650px'><img src='{$image}' class='imgss'/><p align='left'><center>{$Name}<br>{$Description}<br>{$Price}</center></p><p align='right'>{$ExpirtyDate}</p><center><img src='{$Rating}'/></center><br><img src='{$Facebook}'width='20' height='20'align='left'><img src='{$Twitter}'  width='20' height='20' align='left'/> <img src='{$Gmail}'  width='20' height='20' align='left'/><img src='{$Youtube}'  width='20' height='20' align='left'/><img src='{$Reddit}'  width='20' height='20' align='left'/><img src='{$Meduim}'  width='20' height='20' align='left'/><img src='{$Myetherwallet}'width='20' height='20' align='left'/><img src='{$neowallet}'width='20' height='20' align='left'/><img src='{$Bitcointalk}'  width='20' height='20' align='left'/<img src='{$kyc}'  width='20' height='20' align='left'/>
        <form method='post' action=''><input type='hidden'  name='link_id' value='".$id."' /><input type='submit' name='like_button' value='Like' name='click' class = 'block'></form>

        ";



        echo "</tr>";
        echo"</div>";
               echo'</td>';



}
?> 
<?php
//pagination
$sql = 'select * from divlink';
$data = $connect->query($sql);
$record = $data->num_rows;
$records_pages = $record/12;
$records_pages = ceil($records_pages);
$prev = $page-1;
$next = $page+1;

echo'<ul class="pagination">';

if($prev >= 1) {

    echo '<li><a href="?page='.$prev.'">prev</a></li>';
}


if($records_pages >=2){
    for($r=1;$r<=$records_pages;$r++){
            $active = $r == $page ? 'class ="active"' : '';
        echo'<li><a href="?page='.$r.'">'.$r.'</a></li>';

}
}
if($next <= $records_pages && $records_pages >= 2) {

    echo '<li><a href="?page='.$next.'">next</a></li>';
}
if($page != $records_pages && $records_pages >= 5){
echo '<li><a href="?page='.$records_pages.'">Last</a></li>';
}

echo '</ul>';


?> 
    </section>

1 个答案:

答案 0 :(得分:0)

将盒子包装在这样的容器中:

<div class="container"> <a></a> <a></a> <a></a> </div>

然后在div下面,可以放置分页

<div></div> <ul class="pagination"></ul>