From: Michael Widenius Date: April 3 1999 10:25am Subject: Counting rows returned from a SELECT with perl DBI. List-Archive: http://lists.mysql.com/mysql/1367 Message-Id: <14085.60499.658095.854092@monty.pp.sci.fi> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit >>>>> "Brian" == Brian Seitz writes: Brian> I am creating a web-front end to search for database entries and I want Brian> to split the output into more than one screen (limit 1 , 20, limit 21 , Brian> 40, etc.) But in order to know when to stop allowing the user to press Brian> "next" and get another screen of results when there are no results left, Brian> I need to return how many total results exist without the limit Brian> statement. Is there a better way to do this than executing the Brian> statement without the limit and doing a count loop (i.e., "while Brian> $row_ref = $sth->fetchrow_arrayref { $i++ } )? It seems like there Brian> should be some DBI function that returns this automatically. Brian> --------------------------------------------------------------------- Brian> Please check "http://www.mysql.com/Manual_chapter/manual_toc.html" before Brian> posting. To request this thread, e-mail mysql-thread1325@stripped Brian> To unsubscribe, send a message to the address shown in the Brian> List-Unsubscribe header of this message. If you cannot see it, Brian> e-mail mysql-unsubscribe@stripped instead. Hi! The 'fastest' way to solve this is to ask for one extra row with the LIMIT clause; You should just not show this last row, but use this to determinate if there is more rows to be shown on the next page. Regards, Monty