how to show fetch array number of results?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
fael097
Forum Commoner
Posts: 34
Joined: Sat Mar 06, 2010 7:57 pm

how to show fetch array number of results?

Post by fael097 »

hi, i have like 93 entries on a database table, divided to show 20 per page, but i wanted to display something like "showing results 1 to 20" on each page, and on the last page, it would display "showing results 81 to 93".
to get the first number, i use the same variable that i use to define where the page starts, but i dont know how to get the last entry that is being displayed. any clues?
thanks in advance!
User avatar
AbraCadaver
DevNet Master
Posts: 2572
Joined: Mon Feb 24, 2003 10:12 am
Location: The Republic of Texas
Contact:

Re: how to show fetch array number of results?

Post by AbraCadaver »

Search this forum for 'pagination'. There are many threads with great examples.
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
fael097
Forum Commoner
Posts: 34
Joined: Sat Mar 06, 2010 7:57 pm

Re: how to show fetch array number of results?

Post by fael097 »

thanks, but my pagination is done, i just need to retrieve this number
jraede
Forum Contributor
Posts: 254
Joined: Tue Feb 16, 2010 5:39 pm

Re: how to show fetch array number of results?

Post by jraede »

If you're doing the pagination with a LIMIT clause in your SQL query, you're going to have to do a separate query first to get the number of rows. You can do that by using mysql_num_rows($result).
Post Reply