PHP Server-Side example SQL query sort order

PHP Server-Side example SQL query sort order

GregPGregP Posts: 500Questions: 10Answers: 0
edited January 2011 in General
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

Replies

  • allanallan Posts: 63,516Questions: 1Answers: 10,472 Site admin
    Hi Greg,

    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
  • GregPGregP Posts: 500Questions: 10Answers: 0
    Works like a charm!

    Cheers,
    Greg
  • allanallan Posts: 63,516Questions: 1Answers: 10,472 Site admin
    Sorted ;-)

    Regards,
    Allan
  • GregPGregP Posts: 500Questions: 10Answers: 0
    edited January 2011
    (watching the joke fly past most North American heads)

    Since my wife's dad is from England and I have a mate living over there, I can enthusiastically say:

    *GROAN*

    (but also *smile*)
  • allanallan Posts: 63,516Questions: 1Answers: 10,472 Site admin
    *snigger*. Glad you got it! I just had to really...

    Allan
This discussion has been closed.