Member Avatar for Borderline

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\">&lt;&lt;  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 &gt;&gt;</a>";}
?></div>

CSS:

#pagination{
	padding-bottom: 10px;}

		#pagination a{
		background-color: red;
		color: white;
		border: 1px;
		border-color: black;
		padding: 2px;}

Try this little trick (not sure if it will help)

div#pagination a {
		background-color: red;
		color: white;
		border: 1px;
		border-color: black;
		padding: 2px;}
Member Avatar for Borderline

Thanks, appreciate the response. Sadly, no change to the result. However, has just dawned on me that at this moment, there isn't enough content to go onto two pages - could this be the cause of the problem?

http://www.craftingswapshop.co.uk/gallery.php

It may be overwrite by another css statement. Test with this:

#pagination a{
background-color: red ! important;
color: white ! important;
border: 1px ! important;
border-color: black ! important;
padding: 2px ! important;}

Make sure your css path is right.

Check on browser view source. Are the pagination links within DIV. If it right, there is only one solution, for using class with the pagination links. In PHP:

<?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\" class=\"pglink\">&lt;&lt; Previous</a> ";}
for($i = 1; $i <= $total_pages; $i++) {
if ($page == $i) {
echo "$i ";}
 
else {
echo "<a href=\"?page=$i\" class=\"pglink\"> $i</a> ";}}
if ($page < $total_pages) {
$next = ($page + 1);
echo "<a href=\"?page=$next\" class=\"pglink\">Next &gt;&gt;</a>";
?>

In CSS:

#pagination a.pglink {
    background-color: red;
    color: white;
    border: 1px;
    border-color: black;
    padding: 2px;}

It should be work. Good luck..

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.