vinpkl Posted December 17, 2008 Share Posted December 17, 2008 hi all like the pagination in this forum, i want to hightlight the page number in my pagination. here is code of for loop which displays page number. i want to apply diferent "style class" to current page and diferent "style class" to other pages. at present all number are coming as same $page = intval($_GET['page']); if ($page < 1 || $page > $total_pages) { $page = 1; } $offset = ($page - 1) * $records_per_page; echo "No. of Pages"; for ($i = 1; $i <= $total_pages; $i++) { if ($i == $page) { $class = 'class="paging"'; $prepend = 'Page '; } echo "<a href=products-".$dealer_id . $i. $class . ">" .$prepend. $i . "</a>\n"; unset($class, $prepend); } vineet Quote Link to comment Share on other sites More sharing options...
fooDigi Posted December 17, 2008 Share Posted December 17, 2008 i don't think your outputting your html correctly. your 'echo' statement... echo "<a href=products-".$dealer_id . $i. $class . ">" .$prepend. $i . "</a>\n"; would result with this... <a href=products-dealerid9class=paging>.... etc,... check your resulting code in the browser. if you use firefox, a very good debugger is called firebug. check it out. Quote Link to comment Share on other sites More sharing options...
vinpkl Posted December 17, 2008 Author Share Posted December 17, 2008 i don't think your outputting your html correctly. your 'echo' statement... echo "<a href=products-".$dealer_id . $i. $class . ">" .$prepend. $i . "</a>\n"; would result with this... <a href=products-dealerid9class=paging>.... etc,... check your resulting code in the browser. if you use firefox, a very good debugger is called firebug. check it out. hi fooDigi actually the linking has been done by search engine guy by shortening urls and its working fine. That part he handles. i just need a style class for my pagination with separate class for curent page. at preset i m using <style type="text/css"> A.paging {background: #FFCC00; text-decoration: none; color:#FFFFFF} A.paging:visited {background: black; text-decoration: none; color:#FFFFFF} A.paging:active {background: #FFCC00; text-decoration: none; color:#FFFFFF} A.paging:hover {background: #FFCC00; font-weight:bold; color:#FFFFFF} </style> but neither it works in IE7 nor FF3. i need something that can be done severside. vineet Quote Link to comment Share on other sites More sharing options...
fooDigi Posted December 17, 2008 Share Posted December 17, 2008 if you have an html code sample of exactly what you need, i may help you with the css. Quote Link to comment Share on other sites More sharing options...
vinpkl Posted December 17, 2008 Author Share Posted December 17, 2008 if you have an html code sample of exactly what you need, i may help you with the css. here is my html sample. if you do in this. i want when i click one link then other links should be of separte link to show that i selected the particular number link. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Untitled Document</title> <style type="text/css"> A:link {background: #FFCC00; text-decoration: none; color:#FFFFFF} A:visited {background: black; text-decoration: none; color:#FFFFFF} A:active {background: #FFCC00; text-decoration: none; color:#FFFFFF} A:hover {background: #FFCC00; font-weight:bold; color:#FFFFFF} </style> </head> <body> <a href="#">1</a> <a href="#">2</a> <a href="#">3</a> <a href="#">4</a> </body> </html> or something like the pic i have attached vineet [attachment deleted by admin] Quote Link to comment Share on other sites More sharing options...
fooDigi Posted December 17, 2008 Share Posted December 17, 2008 once you click one of the pagination links, the page should "reload" with the new page number, right... then just assign a css class to the selected number... <style type="text/css"> .selected{background: #ccff00} </style> <a href="#">1</a> <a href="#" class="selected">2</a> <a href="#">3</a> <a href="#">4</a> Quote Link to comment Share on other sites More sharing options...
vinpkl Posted December 17, 2008 Author Share Posted December 17, 2008 once you click one of the pagination links, the page should "reload" with the new page number, right... then just assign a css class to the selected number... <style type="text/css"> .selected{background: #ccff00} </style> <a href="#">1</a> <a href="#" class="selected">2</a> <a href="#">3</a> <a href="#">4</a> hi fooDigi i m not writing my paging or pages manually. its coming with the pagination script. so i cannot manually write class="selected" on the link which user will select. this html sample i gave u because u said u can help me if i provide u with html sample. so tell me how can i implement it in pagination script <?php $page = intval($_GET['page']); if ($page < 1 || $page > $total_pages) { $page = 1; } $offset = ($page - 1) * $records_per_page; echo "No. of Pages"; for ($i = 1; $i <= $total_pages; $i++) { if ($i == $page) { $class = 'class="paging"'; $prepend = 'Page '; } echo "<a href=products-".$dealer_id . $i. $class . ">" .$prepend. $i . "</a>\n"; unset($class, $prepend); } ?> vineet Quote Link to comment Share on other sites More sharing options...
fooDigi Posted December 17, 2008 Share Posted December 17, 2008 to simplify my first response, let's look at this line of code... echo "<a href=products-".$dealer_id . $i. $class . ">" .$prepend. $i . "</a>\n"; for starters, start your "href" attribute out with quotes (href=\")... without them, it may offset other attribute declarations... Quote Link to comment Share on other sites More sharing options...
vinpkl Posted December 17, 2008 Author Share Posted December 17, 2008 to simplify my first response, let's look at this line of code... echo "<a href=products-".$dealer_id . $i. $class . ">" .$prepend. $i . "</a>\n"; for starters, start your "href" attribute out with quotes (href=\")... without them, it may offset other attribute declarations... hi foodigi if i start my href with \" then where should i close the opeing quotes or slash. can u do in below line <?php echo "<a href=\"products-".$dealer_id . $i. $class . ">" .$prepend. $i . "</a>\n"; ?> vineet Quote Link to comment Share on other sites More sharing options...
fooDigi Posted December 17, 2008 Share Posted December 17, 2008 just make sure the resulting html works... not sure what the dealer is, but the following should echo something similar... echo "<a href=\"products-".$dealer_id."-".$i.".html\" class=\"$class\">" .$prepend. $i . "</a>\n"; "could" result in... <a href="products-435-7.html" class="some_css_class">whatever</a> Quote Link to comment Share on other sites More sharing options...
vinpkl Posted December 17, 2008 Author Share Posted December 17, 2008 just make sure the resulting html works... not sure what the dealer is, but the following should echo something similar... echo "<a href=\"products-".$dealer_id."-".$i.".html\" class=\"$class\">" .$prepend. $i . "</a>\n"; "could" result in... <a href="products-435-7.html" class="some_css_class">whatever</a> hi i would like to ask that this you have done to make my html clear that i understood. but will it make any solution to separately highlight the current selected page number. vineet Quote Link to comment Share on other sites More sharing options...
fooDigi Posted December 17, 2008 Share Posted December 17, 2008 have you not tried? Quote Link to comment Share on other sites More sharing options...
vinpkl Posted December 17, 2008 Author Share Posted December 17, 2008 have you not tried? ya i have tried it. it does nothing to highlight vineet Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.