> 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
Maybe you could have a hidden field that lists the 30 IDs that are displayed on the page, as a comma separated list. Then, if the user chooses to resort those 30 results, based on another column, you can use that hidden field in your query to limit the IDs. i.e. <input type='hidden' name='display_ids' value='1,4,6,7,8,9'> Where the actual numbers would be generated from your result set. Then, use those numbers in your query. SELECT * FROM table WHERE ... AND ID IN($display_ids) ORDER BY <<new_sort_order>> Hopefully PG supports IN(). My $0.02, I'm sure there are other ways...or maybe this isn't even what you're looking for. :) ---John Holmes... > 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 " "; > > >>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 > > >> > > >> > > >> > > >> > > >> > > > > > > > > > > > > > > > > > > > > > > > > > -- > 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