Evening
I've managed to get a pagination code, but I'm at a loss at how to style the links produced. I've tried placing the pagination code inside a div and then styling the links for this div, but there's no change to the output. Can anyone suggest a solution?
<div id="pagination">
<?php
// mysql
$per_page = 10;
if (!isset($_GET['page']) || !is_numeric($_GET['page'])) {
$page = 1;
}
else {
$page = (int)$_GET['page'];
}
$from = (($page * $per_page) - $per_page);
$data = mysql_query ("SELECT * FROM gallery LIMIT $from, $per_page");
?>
<?php
$total_results =
mysql_fetch_array(mysql_query("SELECT COUNT(*) AS num FROM gallery"));
$total_pages =
ceil($total_results['num'] / $per_page);
if ($page > 1) {
$prev = ($page - 1);
echo "<a href=\"?page=$prev\"><< Previous</a> ";}
for($i = 1; $i <= $total_pages; $i++) {
if ($page == $i) {
echo "$i ";}
else {
echo "<a href=\"?page=$i\">$i</a> ";}}
if ($page < $total_pages) {
$next = ($page + 1);
echo "<a href=\"?page=$next\">Next >></a>";}
?></div>
CSS:
#pagination{
padding-bottom: 10px;}
#pagination a{
background-color: red;
color: white;
border: 1px;
border-color: black;
padding: 2px;}