Re: [PHP] how to resort results of a query

2002-07-05 Thread Chris Hewitt

Matthew,

Apologies to others that this is now quite OT, let's make this the last 
of this thread. If I may suggest that this is now about pure sql 
techniques and nothing to do with php.

What I did was to create a table (not temporary as it happens) with 
fields containing all the fields that you want to display e.g.:
CREATE TABLE searchdata (
username varchar(30),
course varchar2(80),
discipline varchar2(40),
college varchar2(60));
CREATE INDEX course ON searchdata (username, course);
CREATE INDEX discipline ON searchdata (username, discipline);
CREATE INDEX college ON searchdata (username, college);
The username field is either the name the user is logged in as or some 
unique identifier you give to that user.

When you get the main sql statement, copy all the fields into 
searchdata. When you display the fields on your form, make each of the 
headings of the table you display the data in a url to this same form 
but with an "orderby" parameter. So e.g. the "course" column title is a 
url ending in "orderby=course". Now when the form is called with the 
orderby parameter, instead of getting the data from the main table, get 
it from searchdata with an sql statement which includes the relevant 
"order by" clause. You need to arrange for the data to be deleted when 
it is finished with, I leave that to you, each case will differ.

I do not claim that this is the best way, but it is the way I used.

Hope it helps.

Chris

Matthew K. Gold wrote:

>I'm sorry to trouble you further, but if you have a second, can you give me
>some advice on how to store results in a temporary table with the columns
>indexed?  I'm very new to PHP, and I'm not sure how to go about it.
>



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




Re: [PHP] how to resort results of a query

2002-07-05 Thread Matthew K. Gold

Thanks very much for your response, Chris--it sounds like that's exactly
what I need to do.

I'm sorry to trouble you further, but if you have a second, can you give me
some advice on how to store results in a temporary table with the columns
indexed?  I'm very new to PHP, and I'm not sure how to go about it.

Thanks in advance.

best,

Matt


- Original Message -
From: Chris Hewitt <[EMAIL PROTECTED]>
To: Matthew K. Gold <[EMAIL PROTECTED]>
Cc: <[EMAIL PROTECTED]>
Sent: Friday, July 05, 2002 7:34 AM
Subject: Re: [PHP] how to resort results of a query


> Matthew,
>
> Its a new query unless you want to sort using php routines. For a small
> amount of data this is fine but for large amounts there is a performance
> hit. Your choice as to the balance with the amount of data you have.
>
> Where I have a lot of data, extracted from a very large amount of data,
> I store my results in a new, temporary, table that has each field
> indexed. I make the column headings on my html page into links that
> extract the data from the temporary table, ordered by that column. As
> its multi-user, I have a field in the temporary table with the username
> so that each user gets their own data (its first part of the indices too).
>
> Hope this helps
> Chris
>
> Matthew K. Gold wrote:
>
> >Hi,
> >
> >How can I set things up so that a user can resort the results of a query?
> >
> >Also, how can I make certain columns into links?  I'm making a site that
> >will list college courses.  When users decide to browse listings by
> >discipline, or college, I'd like the titles of the courses to be links to
> >fuller descriptions of those courses.  But I'm
> >not sure how to do that.
> >
> >thanks in advance for your help.
> >
> >best,
> >
> >Matt
> >
> >
> >
>


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