Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

League Creation Script Problem

  • 28-02-2007 06:33PM
    #1
    Registered Users, Registered Users 2 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