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



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

Reply via email to