Hi everyone,
i have a very basic pagination code for my site however i would like to adapt the links as they are displayed, so far the script just outputs numbered links but there is no such styling to the link. i would like the active link to be in bold and not clickable. i.e if im on page 4 the page four is in bold with no href! here is my code:
<?php
include ('db-conn.php');
$max = 1; //amount of articles per page. change to what to want
if (isset($_GET['p'])){
$p = $_GET['p'];}
if(empty($p))
{
$p = 1;
}
$limits = ($p - 1) * $max;
//view the news article!
if(isset($_GET['act']) && $_GET['act'] == "view")
{
$id = $_GET['id'];
$sql = mysql_query("SELECT * FROM news WHERE id = '$id'");
while($r = mysql_fetch_array($sql))
{
$title = $r['title'];
$story = $r['story'];
$author = $r['author'];
$story = stripslashes($story);
echo "<div><p>$title</p><p>$author</p><p>$story</p></div>";
echo "<a href=\"".$_SERVER['HTTP_REFERER']."\">Back</a>";
}
}else{
//view all the news articles in rows
$sql = mysql_query("SELECT * FROM news LIMIT ".$limits.",$max") or die(mysql_error());
//the total rows in the table
$totalres = mysql_result(mysql_query("SELECT COUNT(id) AS tot FROM news"),0);
//the total number of pages (calculated result), math stuff...
$totalpages = ceil($totalres / $max);
//the table
while($r = mysql_fetch_array($sql))
{
$id = $r['id'];
$title = $r['title'];
$author = $r['author'];
echo "<h3><a href='news.php?act=view&id=$id'>$title</a></h3><div>$author</div>";
}
echo "Pages to View <br />";
echo "<div id=\"pagination\"";
for($i = 1; $i <= $totalpages; $i++){
//this is the pagination link
echo "<a class=\"pglink\" href='news.php?p=$i'>$i</a>  ";
}
echo "</div>";
}
?>