Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

League Creation Script Problem

Options
  • 28-02-2007 6:33pm
    #1
    Registered Users Posts: 673 ✭✭✭


    Hi,

    I am working on the following code:

    [PHP]<?php
    $sql = "SELECT table_1.field_1, table_2.field_1, table_2.field_2
    FROM table_1, teable_2
    WHERE table_1.league_id = ".$_REQUEST. " AND (table_2.player_1_id != table_2.player_2_id OR table_2.player_2_id != table_2.player_1_id)
    ORDER BY RAND()";

    $result= mysql_query($sql)
    or die(mysql_error());
    $counter = 0;
    while ($teams = mysql_fetch_array($result)) {

    if ($counter == 0) { // if first team save
    $team1 = $teams;
    $counter++;
    }
    else{ // if second team write both to database
    $sql2 = "INSERT INTO table_2
    (player_1_id, player_2_id, league_id)
    VALUES
    ('".$team1."',
    '".$teams."',
    '".$_REQUEST."'
    )";

    $result_insert = mysql_query($sql2)
    or die("error 1".mysql_error());

    $counter = 0;
    } // end if

    } // end while

    $my_play_each_player++;
    } //end play each player while

    ?>[/PHP]

    Which selects userers from a database and pairs them off randomly. It works fine for that purpose but im having problems when i want to run through the next set of fixtures as i need to make sure that the same players dont play each other again.

    Ive tried adding a mysql select to check if this fixture already exists but if i do this it just stops when it finds a fixture that has already been done.

    Anyone know how i can set about doing this?

    Thanks


Advertisement