473,466 Members | 1,298 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

first-prev-next-last using PHP

Hi Everyone,

I was developing a browser based software and one of the features of
that software is that it will search some products with some matching
criteria and the result will be displayed the product names as a
links. Sometimes I got few thousands of product names and I want to
show 30 items at a time using html. I was using MySql as database and
PHP for programming.

Could anybody tell me how it is possible to show the result with 30
items each time having "first-prev-next-last" links? Where to store
the result? How can handle multiple user access?

Thanks
AR
Jul 17 '05 #1
8 3762
On 2003-12-07, AR John <ar********@yahoo.com> wrote:
Hi Everyone,

I was developing a browser based software and one of the features of
that software is that it will search some products with some matching
criteria and the result will be displayed the product names as a
links. Sometimes I got few thousands of product names and I want to
show 30 items at a time using html. I was using MySql as database and
PHP for programming.

Could anybody tell me how it is possible to show the result with 30
items each time having "first-prev-next-last" links? Where to store
the result? How can handle multiple user access?


AFAIK there is no way to store resultsets. So you would have to perform
the query for each page, and then use LIMIT limit,offset to filter out
the rows you want to show. Having an index on the columns you use for
your selection might speed things up.

--
verum ipsum factum
Jul 17 '05 #2
Tom
You may want to have a look at this tutorial:
http://www.phpfreaks.com/tutorials/73/0.php

"Tim Van Wassenhove" <eu**@pi.be> wrote in message
news:bq*************@ID-188825.news.uni-berlin.de...
On 2003-12-07, AR John <ar********@yahoo.com> wrote:
Hi Everyone,

I was developing a browser based software and one of the features of
that software is that it will search some products with some matching
criteria and the result will be displayed the product names as a
links. Sometimes I got few thousands of product names and I want to
show 30 items at a time using html. I was using MySql as database and
PHP for programming.

Could anybody tell me how it is possible to show the result with 30
items each time having "first-prev-next-last" links? Where to store
the result? How can handle multiple user access?


AFAIK there is no way to store resultsets. So you would have to perform
the query for each page, and then use LIMIT limit,offset to filter out
the rows you want to show. Having an index on the columns you use for
your selection might speed things up.

--
verum ipsum factum

Jul 17 '05 #3
Thanks for the idea.

Tim Van Wassenhove <eu**@pi.be> wrote in message news:<bq*************@ID-188825.news.uni-berlin.de>...
On 2003-12-07, AR John <ar********@yahoo.com> wrote:
Hi Everyone,

I was developing a browser based software and one of the features of
that software is that it will search some products with some matching
criteria and the result will be displayed the product names as a
links. Sometimes I got few thousands of product names and I want to
show 30 items at a time using html. I was using MySql as database and
PHP for programming.

Could anybody tell me how it is possible to show the result with 30
items each time having "first-prev-next-last" links? Where to store
the result? How can handle multiple user access?


AFAIK there is no way to store resultsets. So you would have to perform
the query for each page, and then use LIMIT limit,offset to filter out
the rows you want to show. Having an index on the columns you use for
your selection might speed things up.

Jul 17 '05 #4
AR John wrote:

Could anybody tell me how it is possible to show the result with 30
items each time having "first-prev-next-last" links? Where to store
the result? How can handle multiple user access?


Has anybody tried to store the result into a PHP session (if it is not
too large)? I suppose that would be faster to do and save database
server load...

Jul 17 '05 #5
Adi Schwarz wrote:
AR John wrote:

Could anybody tell me how it is possible to show the result with 30
items each time having "first-prev-next-last" links? Where to store
the result? How can handle multiple user access?


Has anybody tried to store the result into a PHP session (if it is not
too large)? I suppose that would be faster to do and save database
server load...


select *
from mytable
order by some_field
limit zero_based_offset, record_count;

HTH

Matt
Jul 17 '05 #6
Matty wrote:
Adi Schwarz wrote:

AR John wrote:
Has anybody tried to store the result into a PHP session (if it is not
too large)? I suppose that would be faster to do and save database
server load...

select *
from mytable
order by some_field
limit zero_based_offset, record_count;


Of course that works, but the point is that this query is executed once
for every page of the result set -> the server gets all rows, sorts them
and then takes the rows he needs (normally the minority of all rows) -
for every single page, always (almost) the same query. I would say it
saves database server load if this is only done once.

-as

Jul 17 '05 #7
Adi Schwarz wrote:
select *
from mytable
order by some_field
limit zero_based_offset, record_count;


Of course that works, but the point is that this query is executed once
for every page of the result set -> the server gets all rows, sorts them
and then takes the rows he needs (normally the minority of all rows) -
for every single page, always (almost) the same query. I would say it
saves database server load if this is only done once.


Depends on how your code is written, whether you use persistent
connections, etc. Bear in mind, that if the user is only likely to want
to see 10 records, then it's maybe a little wasteful to fetch 2000 that
they won't ever see.

If you're talking about caching the actual data returned, then look at
using an application-level cache. I personally go the roll-your-own
route, but PEAR has a Pear::Cache class (or similar) that does this.

And just how large would the entire result be? How much do you want to pull
across the network connection to the DB server, how much do you want to
serialize/deserialize to/from disk?

Better still, why not just look at caching the page output (depending on
your application), saving executing most of your php and database code at
all?
Jul 17 '05 #8
On 2003-12-12, Adi Schwarz <ad**********************@gmx.at> wrote:
Matty wrote:
Adi Schwarz wrote:

AR John wrote:
Has anybody tried to store the result into a PHP session (if it is not
too large)? I suppose that would be faster to do and save database
server load...

select *
from mytable
order by some_field
limit zero_based_offset, record_count;


Of course that works, but the point is that this query is executed once
for every page of the result set -> the server gets all rows, sorts them
and then takes the rows he needs (normally the minority of all rows) -
for every single page, always (almost) the same query. I would say it
saves database server load if this is only done once.


You could create a temporary table, insert the rows in there...
And then retrieve data from this table,...

--
verum ipsum factum
Jul 17 '05 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Mel | last post by:
i want to have a block, like some articles i see, with the first char (very Fancy and huge) and have the rest of the block kind of wrap around this char (to the right of). something like below...
12
by: Alan J. Flavell | last post by:
OK, today's email brought a comment from a reader, pointing out something that I'd long since noticed myself but hadn't done anything about it. On my pages, I've got a first-letter style on...
6
by: Veerle | last post by:
Hi, Somewhere in my html page, I have the following code: <div id="main-body"> <h2>Header text</h2> <p>Some other text ...</p> ..... <h2>Another header text</h2> <p>Some more other text...
8
by: Henrik Larsson | last post by:
Hi, I need help with selecting the following rows from a table looking like this: ID IP Query 1 -> 1 2.2.2.2 (ie first IP 1 1.1.1.1 <- Query 2 for each...
8
by: Robert Gravereaux | last post by:
I've noticed that the first exception thrown/caught by an app running in debug is very slow - it takes perhaps 7 or 8 seconds on my P4 machine. I've noticed this on several different machines...
43
by: Roger L. Cauvin | last post by:
Say I have some string that begins with an arbitrary sequence of characters and then alternates repeating the letters 'a' and 'b' any number of times, e.g. "xyz123aaabbaabbbbababbbbaaabb" I'm...
13
by: howa | last post by:
e.g. <div class="main"> <p>ssssss</p> <p>ssssss</p> <p>ssssss</p> <p>ssssss</p>
4
by: Milan Krejci | last post by:
int first=15,latest=15; QString typ=NULL; std::map<int,std::string>::iterator i; for(i = SeznamPracovniDoby.begin(); i != SeznamPracovniDoby.end(); i++) { if (typ==NULL) typ=i->second.c_str(); if...
14
by: cs | last post by:
Hi, I'm new to C and would appreciate any feedback on the following program, asplit, which splits a file into 2 new files, putting a certain number of lines in the first file, and all the rest...
3
by: dmalhotr2001 | last post by:
Hi, For string extraction function in vb, if I feed in a paragraph, how do I extract the first sentence of that paragraph. Thanks :D
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.