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
>>
>>
>>
>>    
>>
>
>
>  
>




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

Reply via email to