使用For循环在PHP中分页

时间:2016-03-30 15:08:06

标签: php mysql pagination

echo "<ul class ='pagination'>";
                for ($b=1;$b<=$a;$b++)
                { 

                    ?><li><a href = "pbycategories.php?page=<?php echo $b; ?>"><?php echo $b; ?></a></li><?php 


                }


                echo "</ul>";

    ul.pagination {
display: inline-block;
padding: 0;
margin: 0;

}

ul.pagination li {display: inline;}

ul.pagination li a {
color: black;
float: left;
padding: 8px 16px;
text-decoration: none;
transition: background-color .3s;
border: 1px solid #ddd;

}

 .pagination li:first-child a {
border-top-left-radius: 5px;
border-bottom-left-radius: 5px;
}

.pagination li:last-child a {
border-top-right-radius: 5px;
    border-bottom-right-radius: 5px;
}

ul.pagination li a.active {
background-color: #4CAF50;
color: white;
border: 1px solid #4CAF50;
}

ul.pagination li a:hover:not(.active) {background-color: #ddd;}

我需要帮助for for循环..我的分页看起来像这样

1 ----- 2 ----- 3 ----- 4

5 ------- 6 ----- 7 ----- 8

0 个答案:

没有答案