Jump to content

PHP Pagination not showing CSS styling


Russia

Recommended Posts

Hey guys, I have a PHP pagination script, but for some reason the while looping part that shows each row doesnt show the css styling I have.

 

Here is my code.

 


<?php


    $tableName="news";        
    $targetpage = "archive.php";     
    $limit = 10; 
    
    $query = "SELECT COUNT(*) as num FROM $tableName";
    $total_pages = mysql_fetch_array(mysql_query($query));
    $total_pages = $total_pages['num'];
    
    $stages = 3;
    $page = mysql_escape_string($_GET['page']);
    if($page){
        $start = ($page - 1) * $limit; 
    }else{
        $start = 0;    
        }    
    
    // Get page data
    $query1 = "SELECT * FROM $tableName LIMIT $start, $limit";
    $result = mysql_query($query1);
    
    // Initial page num setup
    if ($page == 0){$page = 1;}
    $prev = $page - 1;    
    $next = $page + 1;                            
    $lastpage = ceil($total_pages/$limit);        
    $LastPagem1 = $lastpage - 1;                    
    
    
    $paginate = '';
    if($lastpage > 1)
    {    
    

    
    
        $paginate .= "<div class='paginate'>";
        // Previous
        if ($page > 1){
            $paginate.= "<a href='$targetpage?page=$prev'>previous</a>";
        }else{
            $paginate.= "";    }
            

        
        // Pages    
        if ($lastpage < 7 + ($stages * 2))    // Not enough pages to breaking it up
        {    
            for ($counter = 1; $counter <= $lastpage; $counter++)
            {
                if ($counter == $page){
                    $paginate.= "<span class='current'>$counter</span>";
                }else{
                    $paginate.= "<a href='$targetpage?page=$counter'>$counter</a>";}                    
            }
        }
        elseif($lastpage > 5 + ($stages * 2))    // Enough pages to hide a few?
        {
            // Beginning only hide later pages
            if($page < 1 + ($stages * 2))        
            {
                for ($counter = 1; $counter < 4 + ($stages * 2); $counter++)
                {
                    if ($counter == $page){
                        $paginate.= "<span class='current'>$counter</span>";
                    }else{
                        $paginate.= "<a href='$targetpage?page=$counter'>$counter</a>";}                    
                }
                $paginate.= "...";
                $paginate.= "<a href='$targetpage?page=$LastPagem1'>$LastPagem1</a>";
                $paginate.= "<a href='$targetpage?page=$lastpage'>$lastpage</a>";        
            }
            // Middle hide some front and some back
            elseif($lastpage - ($stages * 2) > $page && $page > ($stages * 2))
            {
                $paginate.= "<a href='$targetpage?page=1'>1</a>";
                $paginate.= "<a href='$targetpage?page=2'>2</a>";
                $paginate.= "...";
                for ($counter = $page - $stages; $counter <= $page + $stages; $counter++)
                {
                    if ($counter == $page){
                        $paginate.= "<span class='current'>$counter</span>";
                    }else{
                        $paginate.= "<a href='$targetpage?page=$counter'>$counter</a>";}                    
                }
                $paginate.= "...";
                $paginate.= "<a href='$targetpage?page=$LastPagem1'>$LastPagem1</a>";
                $paginate.= "<a href='$targetpage?page=$lastpage'>$lastpage</a>";        
            }
            // End only hide early pages
            else
            {
                $paginate.= "<a href='$targetpage?page=1'>1</a>";
                $paginate.= "<a href='$targetpage?page=2'>2</a>";
                $paginate.= "...";
                for ($counter = $lastpage - (2 + ($stages * 2)); $counter <= $lastpage; $counter++)
                {
                    if ($counter == $page){
                        $paginate.= "<span class='current'>$counter</span>";
                    }else{
                        $paginate.= "<a href='$targetpage?page=$counter'>$counter</a>";}                    
                }
            }
        }
                    
                // Next
        if ($page < $counter - 1){ 
            $paginate.= "<a href='$targetpage?page=$next'>next</a>";
        }else{
            $paginate.= "<span class='disabled'>next</span>";
            }
            
        $paginate.= "</div>";        
    
    
}
//echo $total_pages.' Results';
// pagination
echo $paginate;
?>
                                <div class="newsBorder">
    <table cellspacing="0" border="0" id="newsList" class="width100">
<tbody>
<tr class="row_a">
<td width="30%" class="1 first" id="titleCat">
<b>Category</b>
</td>
<td width="50%" class="item" id="titleTitle">
<b>News Item</b>
</td>
<td width="20%" align="right" class="date">
<b>Date</b>
</td>
</tr>
                    </tbody>

                    </table>
                    



<?php 


        while($row = mysql_fetch_array($result))
        {
        
        
?>        
<tr class="pad">

<td valign="top">
<a href="list.ws?cat=3&page=1" class="catLink">
<img alt="" src="http://www.runescape.com/img/news/mini_customer_support.gif">
<span>Website</span>
</a>
</td>

<td valign='middle'><a href="news.php?newsid=<?php echo $row['newsid'] ?>" class="titleLink"><?php echo $row['title']; ?> </a></td>

<td valign="middle" align="right" class="date"><?php echo $row['dtime']; ?></td></tr><br>
            <?php
        }
    ?>

    </div>
    

 

Here is how it looks right now:

nuo0q.png

 

Here is how I want it to look like.

adLhv.png

 

Its basically everything inside the while is not formatting.

 

I have all the CSS I need so that isnt the problem.

 

Thanks for the help ahead of time.

Link to comment
https://forums.phpfreaks.com/topic/231187-php-pagination-not-showing-css-styling/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.