Click here to Skip to main content
15,887,175 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Nowadays I am working on PHP project everything is perfectly fine hopefully but the issue is in my web that I am using pagination in my site but pagination actually shows on footer but in my site it's shown on right side on my page can you guys please help me how can I correct this issue you can see screenshot for better understanding.

https://i.stack.imgur.com/ssnTn.png


Thanks in advance

What I have tried:

<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>';


?> 
Posted
Updated 25-Nov-18 17:36pm
v4

1 solution

PHP
<?php
# what is $page is not number? you did not fix it in the previous lines. 
$sql = 'select * from divlink ORDER BY Name ASC Limit '.$page1.', 12';
# is it initialized ->$connect
# is $connect an object of a class? which class?
# Query would create an object of mysqli_result class. Follow the link for better understanding 
#http://php.net/manual/en/class.mysqli-result.php
$data = $connect->query($sql);

# $data is object of mysqli_result. 
#http://php.net/manual/en/class.mysqli-result.php
# suggested-> $row = $data->fetch_array()
# extended suggestion: mysqli::result() default resulttype is  MYSQLI_BOTH, I would suggest MYSQLI_ASSOC only. It will shorten the war by years and save many lives
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>';



}
?>



You have many other issue in your codes
-> your code has serious problem of sql injection.
-> Your query has * in it. Great way to shoot your own foot.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900