PHP Server-Side example SQL query sort order
PHP Server-Side example SQL query sort order
That's a heck of a title for a thread.
In any event!-->
If you write something based off the PHP example, you will find that your sort order is case-sensitive. In other words, lower-case and upper-case are sorted into two separate blocks.
In general terms, the way to get around this is to add either upper() or lower() to your SQL query; however, not being an SQL guy, and with all the concatenation going on to generate the $sOrder in the query, I can't figure out where to wrap upper/lower that doesn't throw me an SQL error.
By cutting out all the logic and just using a bog-standard upper(), I got it to work as a test (forcing this sort on a particular column), but I can't figure out where to slip it into the existing code.
Wish I could have written a thread providing the fix rather than asking a question, but I'm at a loss. ;-)
Thanks!
Greg
In any event!-->
If you write something based off the PHP example, you will find that your sort order is case-sensitive. In other words, lower-case and upper-case are sorted into two separate blocks.
In general terms, the way to get around this is to add either upper() or lower() to your SQL query; however, not being an SQL guy, and with all the concatenation going on to generate the $sOrder in the query, I can't figure out where to wrap upper/lower that doesn't throw me an SQL error.
By cutting out all the logic and just using a bog-standard upper(), I got it to work as a test (forcing this sort on a particular column), but I can't figure out where to slip it into the existing code.
Wish I could have written a thread providing the fix rather than asking a question, but I'm at a loss. ;-)
Thanks!
Greg
This discussion has been closed.
Replies
I never thought of that before in the server-side processing... :-) Try this for the ORDER BY statement:
[code]
if ( isset( $_GET['iSortCol_0'] ) )
{
$sOrder = "ORDER BY ";
for ( $i=0 ; $i
Cheers,
Greg
Regards,
Allan
Since my wife's dad is from England and I have a mate living over there, I can enthusiastically say:
*GROAN*
(but also *smile*)
Allan