On Mon, Jul 27, 2009 at 11:25 AM, Shawn McKenzie<nos...@mckenzies.net> wrote:
> Miller, Terion wrote:
>>
>>
>> On 7/27/09 9:40 AM, "Jim Lucas" <li...@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?
>
> Bastien gave you all the info:
>
> You should look at paging the data here with the OFFSET portion of the
> limit clause
>
> Select * from restaurant [where clause]limit 1000, $offset
>
> where the $offset value can tell you where to start in the 17K rows of
> data so that in effect you show records 1-1000, 1001-2000,
> 2001-3000...then on the page, just provide a set of links of navigate
> the recordset by the user  [ << < 1-1000 1001-2000 2001-3000 > >> ]
>
> ***
>
> So you would generate page that had the first 1000 records and a Next >
> link that linked maybe to the same page with ?start=1001.  Then use the
> $_GET['start'] to generate the next set of results staring at 1001.
>
>
> --
> Thanks!
> -Shawn
> http://www.spidean.com
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

correct

-- 

Bastien

Cat, the other other white meat

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to