limitphp Posted April 23, 2009 Share Posted April 23, 2009 If I use a LIMIT x,y in a sql query, how do i get the actual number of records returned for that page? In other words, I don't want to get the total number that would have been returned if there were no LIMIT, I want to get the actual number returned with the LIMIT? Quote Link to comment https://forums.phpfreaks.com/topic/155361-solved-how-do-you-get-the-actual-number-of-records-returned-when-using-limit/ Share on other sites More sharing options...
premiso Posted April 23, 2009 Share Posted April 23, 2009 mysql_num_rows is that what you are looking for? Quote Link to comment https://forums.phpfreaks.com/topic/155361-solved-how-do-you-get-the-actual-number-of-records-returned-when-using-limit/#findComment-817360 Share on other sites More sharing options...
limitphp Posted April 23, 2009 Author Share Posted April 23, 2009 nevermind....I had the wrong result in there....it works now.... sorry...... thanks... Quote Link to comment https://forums.phpfreaks.com/topic/155361-solved-how-do-you-get-the-actual-number-of-records-returned-when-using-limit/#findComment-817363 Share on other sites More sharing options...
jonsjava Posted April 23, 2009 Share Posted April 23, 2009 I had typed this out before you posted, so I'm going to post this anyways (hate to waste my time) odd question. If your limit is larger than the total found, then a SELECT COUNT(*) as `total_found` FROM `table_name` LIMIT 100; will return the table `total_found`, which has the total it found. If the number is larger than your limit, then that means it reached its limit, so implementing "LIMIT" does no good. Let me explain: Lets say I ran this query: SELECT COUNT(*) as `total_found` FROM `ip_range`; and lets say I received this result: total_found ----------- 512 Ok, I now know that if I set my limit to 100, it will find 100. I also know that if I set my limit to 1024, the maximum that will turn up is 512. Is that making any sense? Quote Link to comment https://forums.phpfreaks.com/topic/155361-solved-how-do-you-get-the-actual-number-of-records-returned-when-using-limit/#findComment-817369 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.