If im showing all the records off my mysql database and its pretty huge, how do i create a simple pagination (e.g. Page: 1 2 3 4 ... 50) so i can have like first 10 records on the main page records.php and then rest continues on the records.php?page=2 and then records.php?page=3 and so on?
MySQL makes paging results very easy using LIMIT. You simply specify the starting record and the offset (number of results to display). You will still need to do a record count of the complete result in another query though since you need to know the total results for correctly building the paged link numbers.
How do i make the page numbers for only the records i have within my database?
Also, if i enter the page records.php which is same as records.php?offset=0 it shows the very first 3 records (depending on my query). But, when i click on the page number "1" which is same as records.php?offset=1, it is showing the next 3 records.
How do i make the script to show the first records when i click the page number "1" that is records.php?offset=1 ?????
Thanks for the link, but thats the site i optained the code and atempted it my self. That site's example didnt work. So far the only code that is still working nicely is 2detailed's code.
But im having a lil problem with the code and i posted the problem above waiting for to reply
Sorry for delay in response. I sort of left it with "fill-in-the-blanks". As you can see is the number 3 is the $rows_per_page variable -- essentially. Likewise with the $page_count = 15 / 3; // 15 being the total amount of rows or the mysql_num_rows($query), and once again the 3 being the $rows_per_page.
Get a count first with somethign like "select count(*) as cnt from ..."
Use count for calculating number of pages, then use MySql Limit offset,start feature to get the page wanted.
don't worry about extra query. The count query execute very fast compare with other query in Mysql.