List:General Discussion« Previous MessageNext Message »
From:Sasha Pachev Date:April 2 1999 6:09pm
Subject:Re: Counting rows returned from a SELECT with perl DBI.
View as plain text  
Brian Seitz wrote:
> 
> I am creating a web-front end to search for database entries and I want
> to split the output into more than one screen (limit 1 , 20, limit 21 ,
> 40, etc.)  But in order to know when to stop allowing the user to press
> "next" and get another screen of results when there are no results left,
> I need to return how many total results exist without the limit
> statement.  Is there a better way to do this than executing the
> statement without the limit and doing a count loop (i.e., "while
> $row_ref = $sth->fetchrow_arrayref { $i++ } )?  It seems like there
> should be some DBI function that returns this automatically.
> 

Maybe I do not entirely understand the question, but I
see a simple solution to what I think the question is
about ( provided your database does not get updated in
between the searches, or such updates is something you
do not consider):

select count (*) from my_table  before show the first
result set.
store the total number of records in the hidden input
and use it for later queries.
-- 
Sasha Pachev
http://www.sashanet.com/ (home)
http://www.direct1.com/ (work)
Thread
Counting rows returned from a SELECT with perl DBI.Brian Seitz2 Apr
  • Re: Counting rows returned from a SELECT with perl DBI.Sasha Pachev2 Apr
  • Re: Counting rows returned from a SELECT with perl DBI.Brian Seitz2 Apr
    • Re: Counting rows returned from a SELECT with perl DBI.Vivek Khera2 Apr
  • Re: Counting rows returned from a SELECT with perl DBI.Daniel Koch2 Apr
  • Re: Counting rows returned from a SELECT with perl DBI.Douglas Brantz3 Apr
  • Counting rows returned from a SELECT with perl DBI.Michael Widenius3 Apr