Imposing a range on what is stored in a session variable
Imposing a range on what is stored in a session variable
am 27.07.2009 16:30:16 von tmiller
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 et=
c
My snippet so far
-----------------------
// Process all results into $_S=
ESSION array =
$position =3D 1; =
while ($row =3D mysql_fetch_array($result)) =
{ $_SES=
SION['fullRestaurantList'][$position] =3D $row; =
$position++; =
foreach(range('1','1000') as $c){ =
($position == $c)
$_SESSION['totalNumberO=
fRestaurants'] =3D $c; } =
=
}
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: Imposing a range on what is stored in a session variable
am 27.07.2009 16:34:04 von Phpster
T24gTW9uLCBKdWwgMjcsIDIwMDkgYXQgMTA6MzAgQU0sIE1pbGxlciwKVGVy aW9uPHRtaWxsZXJA
c3ByaW5nZmkuZ2FubmV0dC5jb20+IHdyb3RlOgo+IEkgd2FudCB0byBzdG9y ZSBvbmx5IDEwMDAg
cmVjb3JkcyBhdCBhIHRpbWUgaW4gdGhlIHNlc3Npb24gdmFyaWFibGUgdGhv dWdodCBJIGNvdWxk
IHVzZSBhIHJhbmdlKDEsMTAwMC4uLi4KPgo+IEhvdyB3b3VsZCB5b3UgZG8g dGhpcywgc3RvcmUg
dGhlIGZpcnN0IDEwMDAgLCB0aGVuIHRoZSBzZWNvbmQgb24gcmVmcmVzaCBl dGMKPgo+IE15IHNu
aXBwZXQgc28gZmFyCj4KPiAtLS0tLS0tLS0tLS0tLS0tLS0tLS0tLQo+IKAg oCCgIKAgoCCgIKAg
oCCgIKAgoCCgIKAgoCCgIKAgoCCgIKAgoCCgIKAvLyBQcm9jZXNzIGFsbCBy ZXN1bHRzIGludG8g
JF9TRVNTSU9OIGFycmF5IKAgoCCgIKAgoCCgIKAgoCCgIKAgoCCgIKAgoCCg IKAgoCCgIKAgoCCg
IKAgoCCgIKAgoCCgIKAgoCCgIKAgoCCgIKAgoCAkcG9zaXRpb24gPSAxOyCg IKAgoCCgIKAgoCCg
IKAgoCCgIKAgoCCgIKAgoCCgIKAgoCCgIKAgoCCgIKAgoCCgIKAgoCCgIKAg oCCgIKAgoCCgIKAg
oCCgIKB3aGlsZSAoJHJvdyA9IG15c3FsX2ZldGNoX2FycmF5KCRyZXN1bHQp KSCgIKAgoCCgIKAg
oCCgIKAgoCCgIKAgoCCgIKAgoCCgIKAgoCCgeyCgIKAgoCCgIKAgoCCgIKAg oCCgIKAgoCCgIKAg
oCCgIKAgoCCgJF9TRVNTSU9OWydmdWxsUmVzdGF1cmFudExpc3QnXVskcG9z aXRpb25dID0gJHJv
dzsgoCCgIKAgoCCgIKAgoCCgIKAgoCCgIKAgoCCgIKAgoCCgIKAgoCRwb3Np dGlvbisrOyCgIKAg
oCCgIKAgoCCgIKAgoCCgIKAgoCCgIKAgoCCgIKAgoCCgIKAgoCCgIKAgoCCg IKAgoCCgIKAgoCCg
IKAgoCCgIKAgoCCgIKAgZm9yZWFjaChyYW5nZSgnMScsJzEwMDAnKSBhcyAk Yyl7IKAgoCCgIKAg
oCCgIKAgoCCgIKAgoCCgIKAgoCCgIKAgoCCgIKAgoCCgIKAgoCCgIKAgKCRw b3NpdGlvbiA9PSAk
YykKPiCgIKAgoCCgIKAgoCCgIKAgoCCgIKAgoCCgIKAgoCCgIKAgoCCgIKAg oCCgIKAgoCCgIKAk
X1NFU1NJT05bJ3RvdGFsTnVtYmVyT2ZSZXN0YXVyYW50cyddID0gJGM7IKAg oCCgIKAgoCCgIKAg
oCCgIKAgoCCgIKAgoCCgIKAgoCCgIKB9IKAgoCCgIKAgoCCgIKAgoCCgIKAg oCCgIKAgoCCgIKAg
oCCgIKAgoCCgIKAgoCCgIKAgoCCgIKAgoCCgIKAgoCCgIKAgoCCgIKAgoCCg IKAgoCCgIKAgoCCg
IKAgoCCgIKAgoCCgIKAgoCCgIKAgoCCgIKAgoCCgIKAgoCCgIKAgoCCgIKAg oCCgIKAgoCCgIKAg
oH0KPgo+IC0tCj4gUEhQIEdlbmVyYWwgTWFpbGluZyBMaXN0IChodHRwOi8v d3d3LnBocC5uZXQv
KQo+IFRvIHVuc3Vic2NyaWJlLCB2aXNpdDogaHR0cDovL3d3dy5waHAubmV0 L3Vuc3ViLnBocAo+
Cj4KCgpUZXJpLAoKRG8geW91IHJlYWxseSBuZWVkIHRoYXQgZGF0YSB0byBw ZXJzaXN0PyBUaGlz
IHdpbGwgbm90IHNjYWxlIGVmZmVjdGl2ZWx5LgotLSAKCkJhc3RpZW4KCkNh dCwgdGhlIG90aGVy
IG90aGVyIHdoaXRlIG1lYXQK
Re: Imposing a range on what is stored in a session variable
am 27.07.2009 16:40:39 von List Manager
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
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: Imposing a range on what is stored in a session variable
am 27.07.2009 16:44:47 von tmiller
Well there are currently about 17000 records in the db, and my manager want=
s to have it only pulling in 1000 at a time as a session range
And why do my code snippets always look so messed up , I put them in using =
the rich text or html settings in my Entourage mail...
They look fine when I send them and then crazy when I see them on a post re=
ply...
Anyways...it's one of those mondays where when we left on Friday all our pa=
ges were working brilliant and now they are all doing strange things, like =
trying to save instead of open
And boss thinks it's the server strain and we need ranged sessions...would =
my thinking on using the foreach(range work though?
On 7/27/09 9:34 AM, "Bastien Koert" wrote:
On Mon, Jul 27, 2009 at 10:30 AM, Miller,
Terion wrote:
> I want to store only 1000 records at a time in the session variable thoug=
ht 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 =3D 1; =
while ($row =3D mysql_fetch_array($result)) =
{ $_SE=
SSION['fullRestaurantList'][$position] =3D $row; =
$position++; =
foreach(range('1','1000') as $c){ =
($position == $c)
> $_SESSION['totalNumber=
OfRestaurants'] =3D $c; } =
=
}
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
Teri,
Do you really need that data to persist? This will not scale effectively.
--
Bastien
Cat, the other other white meat
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: Imposing a range on what is stored in a session variable
am 27.07.2009 16:46:48 von tmiller
On 7/27/09 9:40 AM, "Jim Lucas" wrote:
Miller, Terion wrote:
> I want to store only 1000 records at a time in the session variable thoug=
ht 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 =3D 1; =
while ($row =3D mysql_fetch_array($result)) =
{ $_S=
ESSION['fullRestaurantList'][$position] =3D $row; =
$position++; =
foreach(range('1','1000') as $c){ =
($position == $c)
> $_SESSION['totalNumbe=
rOfRestaurants'] =3D $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?
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: Imposing a range on what is stored in a session variable
am 27.07.2009 16:47:45 von Phpster
On Mon, Jul 27, 2009 at 10:44 AM, Miller,
Terion wrote:
> Well there are currently about 17000 records in the db, and my manager wa=
nts to have it only pulling in 1000 at a time as a session range
> And why do my code snippets always look so messed up , I put them in usin=
g the rich text or html settings in my Entourage mail...
> They look fine when I send them and then crazy when I see them on a post =
reply...
> Anyways...it's one of those mondays where when we left on Friday all our =
pages were working brilliant and now they are all doing strange things, lik=
e trying to save instead of open
> And boss thinks it's the server strain and we need ranged sessions...woul=
d my thinking on using the foreach(range work though?
>
>
>
> On 7/27/09 9:34 AM, "Bastien Koert" wrote:
>
> On Mon, Jul 27, 2009 at 10:30 AM, Miller,
> Terion wrote:
>> I want to store only 1000 records at a time in the session variable thou=
ght 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
>>
>> -----------------------
>> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =
=A0 =A0 =A0 =A0// Process all results into $_SESSION array =A0 =A0 =A0 =A0 =
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0=
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 $position =3D 1; =A0 =A0 =
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0=
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0while (=
$row =3D mysql_fetch_array($result)) =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0{ =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0$_SESSION['fullRestaurantList'][=
$position] =3D $row; =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =
=A0 =A0 =A0 =A0 =A0 =A0$position++; =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0=
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 foreach(range('1','1000') as $c){ =
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0=
=A0 =A0 =A0 =A0 =A0 =A0 ($position == $c)
>> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0$_SESSION['totalNumberOfRestaurants'] =3D $c=
; =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =
=A0} =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0=
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0=
=A0}
>>
>> --
>> PHP General Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>>
>>
>
>
> Teri,
>
> Do you really need that data to persist? This will not scale effectively.
> --
>
> Bastien
>
> Cat, the other other white meat
>
>
>
I would page the data with the LIMIT call as Jim suggested. What is
the user doing with 1K records and how are they getting 1K records?
--=20
Bastien
Cat, the other other white meat
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: Imposing a range on what is stored in a session variable
am 27.07.2009 16:53:16 von Ashley Sheridan
On Mon, 2009-07-27 at 07:44 -0700, Miller, Terion wrote:
> Well there are currently about 17000 records in the db, and my manager wants to have it only pulling in 1000 at a time as a session range
> And why do my code snippets always look so messed up , I put them in using the rich text or html settings in my Entourage mail...
> They look fine when I send them and then crazy when I see them on a post reply...
> Anyways...it's one of those mondays where when we left on Friday all our pages were working brilliant and now they are all doing strange things, like trying to save instead of open
> And boss thinks it's the server strain and we need ranged sessions...would my thinking on using the foreach(range work though?
>
>
>
> On 7/27/09 9:34 AM, "Bastien Koert" wrote:
>
> On Mon, Jul 27, 2009 at 10:30 AM, 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; } }
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
> >
>
>
> Teri,
>
> Do you really need that data to persist? This will not scale effectively.
> --
>
> Bastien
>
> Cat, the other other white meat
>
>
>
The clue to the email formatting is in the list rules if I'm not
mistaken. I believe they say something about sending emails as plain
text, not formatted text, and in any case, the mailing list converts
them all to plain text anyway, hence the messed up appearance.
As to your question, why does your boss think that sessions are the way
to go for this? Doing the limit in the query will be a lot faster and
will need less memory.
Thanks,
Ash
http://www.ashleysheridan.co.uk
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: Imposing a range on what is stored in a session variable
am 27.07.2009 16:54:52 von tmiller
=====3Dsnipped====
>
I would page the data with the LIMIT call as Jim suggested. What is
the user doing with 1K records and how are they getting 1K records?
--
Bastien
Cat, the other other white meat
Here is a link to the code at PasteBin
It's a db full of the town's restaurant inspections that users can look at =
to see what places have violations etc
http://pastebin.ca/1504393
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: Imposing a range on what is stored in a session variable
am 27.07.2009 17:00:47 von Phpster
On Mon, Jul 27, 2009 at 10:54 AM, Miller,
Terion wrote:
>
>
>
> =====snipped====
>>
>
> I would page the data with the LIMIT call as Jim suggested. What is
> the user doing with 1K records and how are they getting 1K records?
>
> --
>
> Bastien
>
> Cat, the other other white meat
>
>
> Here is a link to the code at PasteBin
>
> It's a db full of the town's restaurant inspections that users can look at to see what places have violations etc
>
> http://pastebin.ca/1504393
>
So this is a report that is being run on the data at any particular
moment in time. Is there criteria that can be used to limit the data
range for more efficient queries like:
1. must be in a certain neighborhood or zip code
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 > >> ]
--
Bastien
Cat, the other other white meat
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: Imposing a range on what is stored in a session variable
am 27.07.2009 17:25:12 von List Manager
Miller, Terion wrote:
>
>
> On 7/27/09 9:40 AM, "Jim Lucas" 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?
Why don't you read the docs on it and find out.
http://dev.mysql.com/doc/refman/5.1/en/select.html
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: Imposing a range on what is stored in a session variable
am 27.07.2009 17:25:16 von Shawn McKenzie
Miller, Terion wrote:
>
>
> On 7/27/09 9:40 AM, "Jim Lucas" 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
Re: Imposing a range on what is stored in a session variable
am 27.07.2009 17:35:27 von Phpster
On Mon, Jul 27, 2009 at 11:25 AM, Shawn McKenzie wrot=
e:
> Miller, Terion wrote:
>>
>>
>> On 7/27/09 9:40 AM, "Jim Lucas" wrote:
>>
>> Miller, Terion wrote:
>>> I want to store only 1000 records at a time in the session variable tho=
ught I could use a range(1,1000....
>>>
>>> How would you do this, store the first 1000 , then the second on refres=
h etc
>>>
>>> My snippet so far
>>>
>>> -----------------------
>>> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0=
=A0 =A0 =A0 =A0 // Process all results into $_SESSION array =A0 =A0 =A0 =
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0=
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 $position =3D 1; =A0 =
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0=
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0whi=
le ($row =3D mysql_fetch_array($result)) =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0{ =A0 =A0 =A0 =A0 =A0 =A0 =A0 =
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0$_SESSION['fullRestaurantLis=
t'][$position] =3D $row; =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =
=A0 =A0 =A0 =A0 =A0 =A0 =A0$position++; =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0=
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 foreach(range('1','1000') as $c=
){ =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =
=A0 =A0 =A0 =A0 =A0 =A0 =A0 ($position == $c)
>>> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0=
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 $_SESSION['totalNumberOfRestaurants'] =3D =
$c; =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0=
=A0} =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0=
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0=
=A0}
>>>
>>
>> Use the mysql function for this called LIMIT. =A0It 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 recor=
ds 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 =A0[ << < 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=3D1001. =A0Then use t=
he
> $_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
--=20
Bastien
Cat, the other other white meat
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php