Forum Moderators: coopster

Message Too Old, No Replies

PHP Paging navigation bar

         

bubble

11:30 am on Jan 12, 2009 (gmt 0)

10+ Year Member



My Site use PHP Mysql to display content, I use Dreamweaver CS3 to create pages, I would like to use page navigation bar like google's

First previous 1 2 3 4.. Next Last,

but dreamweaver only let you do a navigation bar as following

First previous Next Last,

say if I want each page display 9 records, how to do PHP code to let page count the total records and creat a page navigation bar with page numbers.

If anyone could help?

Thank you!

Pico_Train

2:31 pm on Jan 12, 2009 (gmt 0)

10+ Year Member



$records = mysql_result or whatever;

$count = count($records);

<?php for ($i = 0; $i <= $count; $i++) { ?>
<a href="http://www.example.com?record_id=<?php echo $record[$i]['id'];?>"><?php echo $i+1;?></a>
<?php } ?>

Something like that should get you on your way. Beware that your first record will be $record[0] so you will have to work around that too!

then you use $_GET['id'] to retrieve the details of specific record with mysql and display it on that page.

[edited by: Pico_Train at 2:33 pm (utc) on Jan. 12, 2009]

bubble

4:57 pm on Jan 12, 2009 (gmt 0)

10+ Year Member



Thank you for that, I shall have a try, I am new in using PHP.