36 users online (1 members and 35 guests)  


  Results 1 to 2 of 2

Related

  1. Javascript array in PHP    Forum: PHP Forum
    Replies: 0
  2. 'Searching' an array    Forum: PHP Forum
    Replies: 8
  3. Replies: 4
  4. re-arrange array    Forum: CGI Perl Forum
    Replies: 1
  5. Help to populate DIV from an array    Forum: Javascript Forum
    Replies: 3
  1. #1
    Zoup's Avatar
    New User

    Status
    Offline
    Join Date
    Mar 2007
    Posts
    8

    multiple array into function

    This is the code i am using to populate my $values array. I believe the way I am trying to populate this array is wrong.

    PHP Code:
                                $values = array(); 

    $query 'Select * from round_info natural join tee where player_id = 1 limit 10'
    $result mysql_query($query); 
    if (!
    $result){ 
            die (
    "Could not query the database: <br />" mysql_error()); 
        } 

    while(
    $row mysql_fetch_array($resultMYSQL_ASSOC)){ 
        
    $values[] = $row['gross_score'] => $row['course_rating'] => $row['course_slope']; 


    $handicap_index[] = handicap_differential($values); 
    </div>
    The function handicap_differential is also wrong i believe. I am passing in an array I want it to do some math with that array values and pass me back another array. Then with that array complete the last foreach statement and give me a handicap back.

    PHP Code:
                                function handicap_differential($values){ 
        
    $value = array(); 
        foreach (
    $values as $gross_score => $course_rating => $slope_rating){ 
            
    value[] = ($gross_score $course_rating) * 113 $slope_rating
        }     
        
    $x 0
        foreach (
    $value as $y){ 
            
    $gross += $y
            
    $x += 1
        } 
        
    $gross = ($gross $x) * .96
        
    $handicap round($gross1); 
        return 
    $handicap

    Any suggestions?

  2. #2
    iLLin's Avatar
    New User

    Status
    Offline
    Join Date
    Mar 2007
    Posts
    2

    Re: multiple array into function

    PHP Code:
    while($row mysql_fetch_array($resultMYSQL_ASSOC)){ 
        
    $values[] = array("gross_score" => $row['gross_score'], "course_rating" => $row['course_rating'], "course_slope" => $row['course_slope']); 

    PHP Code:
    foreach ($values as $row){ 
            
    value[] = ($row['gross_score'] - $row['course_rating']) * 113 $row['slope_rating']; 
        } 
    Look that over and see if that works for ya .




Tags for this Thread