Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Regular Coder
    Join Date
    Jun 2003
    Location
    Australia
    Posts
    528
    Thanks
    8
    Thanked 8 Times in 8 Posts

    Array - Multisort

    Howdy!

    I've been having a little bit of a problem with this for a while now and just can't seem to work out where I've gone wrong.

    Here is the code:

    PHP Code:
    $s mysql_query("SELECT * FROM matches WHERE oldhome=$_REQUEST[teamid] OR oldaway=$_REQUEST[teamid] AND hforfeit=0 AND aforfeit=0 AND washout=0");
    while(
    $r=mfa($s)){
        if (
    $r['oldhome']==$_REQUEST['teamid']) {
            
    $paid $r['hpaid'];
        } else {
            
    $paid $r['apaid'];
        }
        
    $paylist[] = array('Round' => $r['round'], 'Reason' => "Fixtured Game"'Fee' => $gamefee'Credit' => 0'Paid' => $paid);
    }

    $s mysql_query("SELECT * FROM team_credits WHERE tid=$_REQUEST[teamid]");
    while(
    $r=mfa($s)){
        
    $paylist[] = array('Round' => $r['round'], 'Reason' => "$r[reason]"'Fee' => 0'Credit' => $r['amount'], 'Paid' => 0);
    }
    $s mysql_query("SELECT * FROM team_invoice WHERE tid=$_REQUEST[teamid]");
    while(
    $r=mfa($s)){
        
    $paylist[] = array('Round' => $r['round'], 'Reason' => "$r[reason]"'Fee' => $r['amount'], 'Credit' => 0'Paid' => 0);
    }

    foreach (
    $paylist as $key => $row) {
        
    $round[$key]  = $row['Round'];
        
    $reason[$key] = $row['Reason'];
        
    $fee[$key] = $row['Fee'];
        
    $credit[$key] = $row['Credit'];
        
    $paid[$key] = $row['Paid'];
    }
    array_multisort($roundSORT_ASC$reasonSORT_ASC$feeSORT_ASC$creditSORT_ASC$paidSORT_ASC$paylist);

    foreach (
    $paylist as $key => $row){
        echo 
    "Round: $row[Round] - $row[Reason] - $row[Fee] - $row[Credit] - $row[Paid]<br/>";

    This is the output:

    Code:
    [Line 1] Warning: array_multisort() [function.array-multisort]: Argument #9 is expected to be an array or a sort flag in /home/cityside/public_html/dutyreport/view.php on line 79
    [Line 2] Round: 2 - Fixtured Game - 70.00 - 0 - 70
    [Line 3] Round: 3 - Fixtured Game - 70.00 - 0 - 70
    [Line 4] Round: 4 - Fixtured Game - 70.00 - 0 - 35
    [Line 5] Round: 5 - Fixtured Game - 70.00 - 0 - 70
    [Line 6] Round: 7 - Fixtured Game - 70.00 - 0 - 70
    [Line 7] Round: 6 - Fixtured Game - 70.00 - 0 - 70
    [Line 8] Round: 8 - Fixtured Game - 70.00 - 0 - 70
    [Line 9] Round: 9 - Fixtured Game - 70.00 - 0 - 0
    [Line 10] Round: 10 - Fixtured Game - 70.00 - 0 - 0
    [Line 11] Round: 11 - Fixtured Game - 70.00 - 0 - 0
    [Line 12] Round: 12 - Fixtured Game - 70.00 - 0 - 0
    [Line 13] Round: 3 - Half Time Wet Weather - 0 - 35.00 - 0
    This should simply order by Round #, that is the important thing. Based on this, Line 13 should actually be before Line 4, and for some reason Line 6 and 7 and the opposite way round (although I have a feeling this may just be due to the order it is in on the 'matches' database.

    Any help much appreciated!

    Thanks in advance!

    Taylor
    Last edited by Taylor_1978; 10-29-2009 at 03:38 AM.

  • #2
    Regular Coder
    Join Date
    Jun 2003
    Location
    Australia
    Posts
    528
    Thanks
    8
    Thanked 8 Times in 8 Posts
    UGH! Can't believe I just wait almost 2 hours of my time on this... Simple solution was:

    array_multisort($round, SORT_ASC, $paylist);

    Always the way, to post a question after working on it for hours and then solving it yourself 2 minutes later!


  •  

    Posting Permissions

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