isn't this just a matter of doing
order by country, whatever
??

-----Original Message-----
From: John Holmes [mailto:[EMAIL PROTECTED]]
Sent: Thursday, June 06, 2002 1:02 PM
To: [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Subject: RE: [PHP] Modifying the sort order of a query


I still really don't understand. You have a list of documents, 20 per
page. You want to be able to sort it by country or another column, yet
still display them in alphabetical order?

Maybe an example page would help...is this page public anywhere?

Like I said before, if you sort by new columns, then your paging has to
start over back at the beginning. You said it already did this, but it
still is messing up. Is it messing up when you click Next 20? Does it go
back to the old sorting, or what? If you're looking at page 4 sorted by
name, then you want to sort by country, you can't go back to page 4
(well, you can, but it's going to be a whole new page four because of
the new sort order).

Example page will really help here; maybe I'm just slow in visualizing
this. We can take this off the list if necessary, too.

---John Holmes...

> -----Original Message-----
> From: Andre Dubuc [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, June 05, 2002 10:49 PM
> To: [EMAIL PROTECTED]
> Cc: [EMAIL PROTECTED]
> Subject: Re: [PHP] Modifying the sort order of a query
> 
> Hi John,
> 
> Sorry about that. I should have explained what I meant. The basic
problem
> that I'm trying (desparately) to skirt around is a troublesome paging
> problem.
> 
> The basic query loads all files in the db sorted by name. The first
page
> that
> displays has a "Next 20" button that loads the next page, and so on
until
> the
> last page which has no "Next 20" button, but deadends.
> 
> The problem I've faced today, is that I originally allowed a "Sort by
> Country" button to appear on each page -- thereby messing up the
original
> paging. It, of course, returned to the first page (which didn't know
squat
> about whatever the calling page asked for). Thus, the whole thing
froze --
> which is to be expected.
> 
> The resolution, in my mind, is simple: do not have that button
anywhere
> but
> on the first page (it took me a long time to figure that one out, duhh
> :>).
> The second solution, is somewhat better: using a sub-query, which will
> re-paginate all right, but I still need to retain the alpahbetical
order
> of
> names as well. Perhaps I can't have both. (I think I'll have to try
both -
> -
> my mind's a bit blitzed from the problems I've resolved today!)
> 
> So, that's what I'm trying to do. The page I'm working on is a protype
for
> about three other similar ones.
> 
> Regards,
> Andre
> 
> 
> 
> On Wednesday 05 June 2002 10:22 pm, you wrote:
> > What do you mean it'll "trash the current paging" ?? Can you give a
more
> > detailed explanation?
> >
> > Results 30-60 of one result set sorted by a certain column will be
> > totally different than results 30-60 of a result set sorted by a
> > different column.
> >
> > So the paging would have to start over, anyhow. Unless you're
looking to
> > maintain the same 30 results in the new result set, like my previous
> > email mentioned...
> >
> > ---John Holmes...
> >
> > > -----Original Message-----
> > > From: Andre Dubuc [mailto:[EMAIL PROTECTED]]
> > > Sent: Wednesday, June 05, 2002 10:19 PM
> > > To: Miguel Cruz
> > > Cc: [EMAIL PROTECTED]
> > > Subject: Re: [PHP] Modifying the sort order of a query
> > >
> > > Thanks Miguel,
> > >
> > > I haven't tried the sub-query approach yet, but that does seem to
be
> >
> > the
> >
> > > way
> > > to do this. My fear is that it will trash the current paging
(which
> >
> > took
> >
> > > forever to get working with the current setup). Actually, after
trying
> >
> > my
> >
> > > original code again in another smaller select function, I'm
wondering
> > > whether
> > > I even need this refined search option -- it might be a case of
> > > 'overkill'.
> > > Still, it's got my curiosity going.
> > >
> > > The problem seems to be centered on how I wrote the original code
> >
> > (it's
> >
> > > amzing how it's changed!). I think I'll have to re-write using
switch
> > > functions to clarify exactly what I want it to do.
> > >
> > > Regards,
> > > Andre
> > >
> > > On Wednesday 05 June 2002 09:43 pm, you wrote:
> > > > My understanding was that he wanted to see the same 30 rows, but
> >
> > sorted
> >
> > > in
> > >
> > > > a different way.
> > > >
> > > > For instance, he wanted to see entries 30-60 as sorted by age,
but
> >
> > to
> >
> > > have
> > >
> > > > those sorted by height when displayed.
> > > >
> > > > miguel
> > > >
> > > > On Thu, 6 Jun 2002, Bogdan Stancescu wrote:
> > > > > That's at least curious - limiting and offsetting will most
> >
> > certainly
> >
> > > > > affect the results which are then sorted... I don't think
that's
> >
> > what
> >
> > > he
> > >
> > > > > was after. Just my 2c.
> > > > >
> > > > > Bogdan
> > > > >
> > > > > Miguel Cruz wrote:
> > > > > >Try a sub-select:
> > > > > >
> > > > > >SELECT * FROM (SELECT * FROM rap ORDER BY
> > >
> > > rcountry,rcity,rsname,rfname
> > >
> > > > > >DESC LIMIT 30 OFFSET 30) ORDER BY whatever;
> > > > > >
> > > > > >miguel
> > > > > >
> > > > > >On Wed, 5 Jun 2002, Andre Dubuc wrote:
> > > > > >>Apache 1.3.23 + PHP 4.1.2 + PostgreSQL 7.2
> > > > > >>
> > > > > >>I have a query that sorts by name, country, and city, then
pages
> >
> > in
> >
> > > > > >> groups of 30 records. Originally, I had also coded two
buttons:
> > >
> > > "Sort
> > >
> > > > > >> by Country', 'Sort by City' since I wanted to offer users
the
> > >
> > > options
> > >
> > > > > >> of these choices.
> > > > > >>
> > > > > >>Unfortunately, these buttons work well, but re-select the
whole
> > >
> > > shebang
> > >
> > > > > >>(which I guess is to be expected), destroying any paging
that
> >
> > had
> >
> > > > > >> already started. I've tried all sorts of ways, tried
> >
> > re-arranging
> >
> > > the
> > >
> > > > > >> order of execution, but the result is the same.
> > > > > >>
> > > > > >>I'm at a loss on how to proceed. I've deleted the choice
(for
> >
> > now)
> >
> > > and
> > >
> > > > > >> run it as a simple select order by name query.The problem
seems
> >
> > to
> >
> > > be:
> > > > > >> I need a sub-query select function that retains the
original
> >
> > query,
> >
> > > > > >> simply re-organizing it according to the new criteria, and
> >
> > retains
> >
> > > the
> > >
> > > > > >> original paging. (Perhaps I shouldn't care whether the
paging
> >
> > is
> >
> > > > > >> messed up as long as the results are the same.)
> > > > > >>
> > > > > >>I realize that the way it's set up below, it will
automatically
> >
> > send
> >
> > > a
> > >
> > > > > >> NEW query, which is not what I want. I'd like to work with
the
> > >
> > > results
> > >
> > > > > >> of the original query and modify it with the new criteria
> > > > > >>
> > > > > >>Any suggestions how I can achieve this, or whether it's even
> > >
> > > possible?
> > >
> > > > > >> I would greatly appreciate any assistance or comments.
> > >>
> >
>>**********************************************************************
> >
> > *
> >
> > > > > >>***************
> > > > > >>
> > > > > >>Snippet of offending code:
> > > > > >>
> > > > > >><?php
> > > > > >>
> > > > > >>//snippet follows:
> > > > > >>
> > > > > >>print "<input type="submit" name="submit" value="Sort by
> >
> > City">";
> >
> > > > > >>print "&nbsp;";
> > > > > >>print "<input type="submit" name="submit" value="Sort by
> >
> > Country">";
> >
> > > > > >>// more code
> > > > > >>
> > > > > >>if($_POST['submit'] == "Sort by Name"){
> > > > > >>    $query = "SELECT * FROM rap ORDER BY
> > > > > >>    rsname,rfname,rcountry,rcity,DESC LIMIT 30 OFFSET 30";
> > > > > >>}
> > > > > >>elseif($_POST['submit'] == "Sort by Country"){
> > > > > >>            $query = "SELECT * FROM rap ORDER BY
> > > > > >>    rcountry,rcity,rsname,rfname DESC LIMIT 30 OFFSET 30";
> > > > > >>}
> > > > > >>
> > > > > >>//more code, including paging functions
> > > > > >>?>
> > >>
> >
>>**********************************************************************
> >
> > *
> >
> > > > > >>*********************
> > > > > >>
> > > > > >>Tia,
> > > > > >>Andre
> > >
> > > --
> > > Please pray the Holy Rosary to end the holocaust of abortion.
> > > Remember in your prayers the Holy Souls in Purgatory.
> > >
> > > May God bless you abundantly in His love!
> > > For a free Cenacle Scriptural Rosary Booklet:
> >
> > http://www.webhart.net/csrb/
> >
> > > --
> > > PHP General Mailing List (http://www.php.net/)
> > > To unsubscribe, visit: http://www.php.net/unsub.php
> 
> --
> Please pray the Holy Rosary to end the holocaust of abortion.
> Remember in your prayers the Holy Souls in Purgatory.
> 
> May God bless you abundantly in His love!
> For a free Cenacle Scriptural Rosary Booklet:
http://www.webhart.net/csrb/


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

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

Reply via email to