Results 1 to 3 of 3
  1. #1
    Join Date
    Dec 2003

    Unanswered: Manipulating table data ?

    I now have wrote a script to accept scores but now i'm unsure how to use this data for the problem below. I can display all the table info but unsure what to do so that I can write a If else statement to check each row...

    I have a form that inputs a score for each member this is recorded in a table along with the course id. When all the data is entered I need to adjust everyone’s handicap based on certain rules the handicap is stored in a different table. i.e

    · The winnings handicap has 2 strokes deducted from their handicap
    · Anyone with more than 36 points has 0.5 deducted from their handicap
    · Anyone three points below the winner will receive 0.1 onto their handicap
    · Anyone six points below the winner will receive 0.2 onto their handicap.

    The problem is I think I can write the “if else” statements to cover all the eventualities but I have no clue on how to loop the data through the loop.

    Any help would be greatly appreciated.


  2. #2
    Join Date
    Apr 2006
    Denver, Co. USA
    In case you are still working on this, the following should help -
    PHP Code:
    $winning_score x// need the winning score for the following tests...

    // connect to server and select database here

    // query using a SELECT statement to get the rows you want to test for the latest game

    // assume that $result contains the resource from the query

    while ($row mysql_fetch_assoc($result)) {

    // The following assumes that $row['score'] holds the value you are testing for this game

    // calculate a handicap adjustment

    $handicap_adjust 0.0// initialize a floating point variable

    if($row['score'] = $winning_score) {
    $handicap_adjust -= 2.0// deduct 2.0
    $row['score'] > 36) {
    $handicap_adjust -= 0.5// deduct 0.5
    $row['score'] = $winning_score+3) {
    $handicap_adjust += 0.1// add 0.1 // I am assuming that three less than the winning score is actually three over it
    $row['score'] = $winning_score+6) {
    $handicap_adjust += -0.2// add 0.2 // Assuming that six less is actually six over it

    // update the handicap table for the player id by
    // adding the $handicap_adjust variable to the current handicap in the table.

    // end of while loop 

  3. #3
    Join Date
    Dec 2003
    Thanks for the code that helped out so much!!! changed it about abit to add a few more conditions that I had forgot about and its working great. Thats the hardest bit out of the way, its now time to get all the scripts working as one system! oh and I suppose its time to design the site.



Posting Permissions

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