vineet
12-17-2008, 03:21 PM
hi all
taking an example of pagination that has applied on this forum for displaying threads.
i want to hightlight the page number in my pagination.
at present what i m getting is that if there are 4 pages. means page 1,2,3,4. Then all numbers are having black background.
when i click page number 2 then, page number 1 becomes without background and changes to default link colour of browser not my stylesheet. when i click page number 3, then page number 1,2, will become without background with default browser link colour not my stylesheet link color.
The page numbers are not even displaying hover effect on rollover. what is my script doing wrong.
this is css
<style type="text/css">
a.paging:link {background-color: #FFCC00; text-decoration: none; color:#FFFFFF}
a.paging:visited {background-color: black; text-decoration: none; color:#FFFFFF}
a.paging:active {background-color: #FFCC00; text-decoration: none; color:#FFFFFF}
a.paging:hover {background-color: #FFCC00; font-weight:bold; color:#FFFFFF}
</style>
<style type="text/css">
a.pagingCurrent:link {background: #FF0000; text-decoration: none; color:#FFFFFF}
a.pagingCurrent:visited {background: black; text-decoration: none; color:#FFFFFF}
a.pagingCurrent:active {background: #FF0000; text-decoration: none; color:#FFFFFF}
a.pagingCurrent:hover {background: #FF0000; font-weight:bold; color:#FFFFFF}
</style>
here is code of php loop which displays page numbers.
<?php
$dealer_id=$_REQUEST['dealer_id'];
$category_id=$_REQUEST['category_id'];
$sql = "SELECT * FROM product_table where dealer_id=$dealer_id";
$q = mysql_query($sql);
$total_records = mysql_num_rows($q);
$records_per_page = 1;
$total_pages = ceil($total_records / $records_per_page);
$page = intval($_GET['page']);
if ($page < 1 || $page > $total_pages) {
$page = 1;
}
$offset = ($page - 1) * $records_per_page;
$sql = "SELECT * FROM product_table where dealer_id=$dealer_id LIMIT $offset, $records_per_page";
$result=mysql_query($sql);
while($row = mysql_fetch_array($result))
{
$desc = substr($row['detail_description'], 0, 250);
echo "<td valign=top class='des' width=250>". $desc . "</td>";
echo "</tr>";
echo "<tr>";
}
echo "No. of Pages";
for ($i = 1; $i <= $total_pages; $i++)
{
if ($i == $page) {
$class = 'pagingCurrent';
$prepend = 'Page';
}
else
{
$class = 'paging';
$prepend = 'Page';
}
echo "<a href='products-".$dealer_id."-". $category_id. "-". $i. ".html' class='" . $class . "'>" . $prepend. $i . "</a>\n";
unset($class, $prepend);
}
?>
vineet
taking an example of pagination that has applied on this forum for displaying threads.
i want to hightlight the page number in my pagination.
at present what i m getting is that if there are 4 pages. means page 1,2,3,4. Then all numbers are having black background.
when i click page number 2 then, page number 1 becomes without background and changes to default link colour of browser not my stylesheet. when i click page number 3, then page number 1,2, will become without background with default browser link colour not my stylesheet link color.
The page numbers are not even displaying hover effect on rollover. what is my script doing wrong.
this is css
<style type="text/css">
a.paging:link {background-color: #FFCC00; text-decoration: none; color:#FFFFFF}
a.paging:visited {background-color: black; text-decoration: none; color:#FFFFFF}
a.paging:active {background-color: #FFCC00; text-decoration: none; color:#FFFFFF}
a.paging:hover {background-color: #FFCC00; font-weight:bold; color:#FFFFFF}
</style>
<style type="text/css">
a.pagingCurrent:link {background: #FF0000; text-decoration: none; color:#FFFFFF}
a.pagingCurrent:visited {background: black; text-decoration: none; color:#FFFFFF}
a.pagingCurrent:active {background: #FF0000; text-decoration: none; color:#FFFFFF}
a.pagingCurrent:hover {background: #FF0000; font-weight:bold; color:#FFFFFF}
</style>
here is code of php loop which displays page numbers.
<?php
$dealer_id=$_REQUEST['dealer_id'];
$category_id=$_REQUEST['category_id'];
$sql = "SELECT * FROM product_table where dealer_id=$dealer_id";
$q = mysql_query($sql);
$total_records = mysql_num_rows($q);
$records_per_page = 1;
$total_pages = ceil($total_records / $records_per_page);
$page = intval($_GET['page']);
if ($page < 1 || $page > $total_pages) {
$page = 1;
}
$offset = ($page - 1) * $records_per_page;
$sql = "SELECT * FROM product_table where dealer_id=$dealer_id LIMIT $offset, $records_per_page";
$result=mysql_query($sql);
while($row = mysql_fetch_array($result))
{
$desc = substr($row['detail_description'], 0, 250);
echo "<td valign=top class='des' width=250>". $desc . "</td>";
echo "</tr>";
echo "<tr>";
}
echo "No. of Pages";
for ($i = 1; $i <= $total_pages; $i++)
{
if ($i == $page) {
$class = 'pagingCurrent';
$prepend = 'Page';
}
else
{
$class = 'paging';
$prepend = 'Page';
}
echo "<a href='products-".$dealer_id."-". $category_id. "-". $i. ".html' class='" . $class . "'>" . $prepend. $i . "</a>\n";
unset($class, $prepend);
}
?>
vineet