Re: Imposing a range on what is stored in a session variable

From: Date: Mon, 27 Jul 2009 14:46:48 +0000
Subject: Re: Imposing a range on what is stored in a session variable
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-295883@lists.php.net to get a copy of this message
On 7/27/09 9:40 AM, "Jim Lucas" <lists@cmsws.com> wrote: Miller, Terion wrote: > I want to store only 1000 records at a time in the session variable thought I could use a > range(1,1000.... > > How would you do this, store the first 1000 , then the second on refresh etc > > My snippet so far > > ----------------------- > // Process all results into $_SESSION array > $position = 1; > while ($row = mysql_fetch_array($result)) > { > $_SESSION['fullRestaurantList'][$position] = $row; > $position++; > foreach(range('1','1000') as $c){ > ($position == $c) > > $_SESSION['totalNumberOfRestaurants'] = $c; } > > } > Use the mysql function for this called LIMIT. It LIMITs the amount of data returned. SELECT * FROM table_name LIMIT 1000 1. it will make your SQL calls much faster 2. it will use less memory But that limits results right, if a query generated more then 1000 records how would a user be able to access 1001 ..put the query in a loop?

« previous php.general (#295883) next »