Page 2 of 2 FirstFirst 12
Results 11 to 17 of 17

Thread: How to sort MySQL data using the last word/date

  1. #11
    Join Date
    Jan 2008
    Posts
    4,168
    Thanks
    28
    Thanked 628 Times in 624 Posts
    Blog Entries
    1

    Default

    Can I also see the code that does the left side of the page (all of it)? The right wont help me very much.. :\
    Jeremy | jfein.net

  2. #12
    Join Date
    May 2007
    Location
    South Africa
    Posts
    175
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default

    Hi,

    The most recent submission is for the right hand side and everything in post #6 of this thread is for the left hand side.

    I have now posted "All of it"

  3. #13
    Join Date
    Jan 2008
    Posts
    4,168
    Thanks
    28
    Thanked 628 Times in 624 Posts
    Blog Entries
    1

    Default

    Where does the $counter variable come from?
    Jeremy | jfein.net

  4. #14
    Join Date
    May 2007
    Location
    South Africa
    Posts
    175
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default

    Hi,

    I am not a person who knows anything about php or script in this regard.

    I have basically used a cut and past system to get it to where it is , with the help of folk like yourself.

    The counter is used I understand to count the rows for each speific tournament and then place the respective number no of entrants next to the name of the respective tournament.

    sorry I cant help much further with this

  5. #15
    Join Date
    Jan 2007
    Location
    Davenport, Iowa
    Posts
    2,413
    Thanks
    101
    Thanked 115 Times in 113 Posts

    Default

    I can look at it some more later, but I think there is enough code for us to work with now. His sql query is a little odd in that it is ordered by multiple columns, which makes no sense.

    Code:
    select * from _Form_Nr_4 ORDER BY `Date` ASC, `my_sajgf_division:` ASC, `surname` ASC
    should be:
    Code:
    SELECT * FROM _Form_Nr_4 ORDER BY Date ASC
    Also, the variable for date has not been assigned.

    $counter should probably be looked at as well.
    To choose the lesser of two evils is still to choose evil. My personal site

  6. #16
    Join Date
    May 2007
    Location
    South Africa
    Posts
    175
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default

    Hi James,

    Thanks for taking a look at the file.

    In tackling the first section :

    Code:
    select * from _Form_Nr_4 ORDER BY `Date` ASC, `my_sajgf_division:` ASC, `surname` ASC
    I founfd that by assigning it like this I managed to get the table on the right to sort in a fashion I found favourable:

    First by the DATE of tournament, then by the division the player belongs to and lastly in alphabeticla order of surname in the division the play belongs to. Maybe there is a better way of presenting this -I am not sure - That sections works perfectly.

    The assigning of the DATE variable is the challenge of immediate need as once the Date can be retreived for the right hand side of the page then it will be easy to allocate it.

    Thanks for all you inputs

    Regards
    Rob

  7. #17
    Join Date
    Jan 2007
    Location
    Davenport, Iowa
    Posts
    2,413
    Thanks
    101
    Thanked 115 Times in 113 Posts

    Default

    I stand corrected. Your date is defined. I did not see it there the first time. I usually assign $row['date'] to $date, which is probably why I missed it. From what I can see things look pretty good, but clearly there is something we are missing.

    I notice that several of your initial values are empty. For example, in the first loop of:

    Code:
    if($i > 0 AND $row['i_wish_to_play'] != $last_wish_to_play)
    $i and $last_wish_to_play always have an empty value, so it will always fail the first time through. Also, $counter[$firstNAsAString] will always be true since it is empty as well.

    Just letting you know. I suspect you already knew though. As to the main problem. Try inserting this line at various places in your code one at a time:

    Code:
    $date=$row['Date']; echo "$date";
    to see where the date value is either not being assigned or lost.
    To choose the lesser of two evils is still to choose evil. My personal site

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •