开发者

check mysql result against array for duplicates

I have researched this to no avail and thought I'd inquire here since the group of folks at SO seems to be really well informed.

Here's the situation. I have a database in which I've got matches stored to create a result/schedule for a league app I'm working on. Everything is fine except my last error check. Basically what I want to do is check that the teams selected in a form aren't already playing on the date selected when making the schedule. i.e. TEAM1 and TEAM2 are playing on April 20th, 2011 (this is already in the db) and when the league admin is making up a schedule I want to make sure that neither of those teams can be scheduled to play again on that date.

Here's the code I've got so far:

    //check to make sure none of the teams are already scheduled to play on the same date
    $resultarray = "";
    $querydate = $_POST['date'];
    $queryseason = $_SESSION['SEASON_ID'];
    $sql2="SELECT MATCH_TEAM1_ID, MATCH_TEAM2_ID FROM MATCHES WHERE SEASON_ID ='$queryseason' AND MATCH_DATE='$querydate'";
    $result2=mysql_query($sql2) or die(mysql_error());

    $teamdateerror = false;

    $resultSet = array();
    while($resultarray = mysql_fetch_array($result2)){
        $resultSet[] = $resultarray;
    }

    $commonteamcheck = array_intersect($resultset,$allteams);

    vardump($commonteamcheck);

    if ($commonteamcheck != ""){
        $teamdateerror = true;
    }

The above always results in an error : Warning: array_intersect() [function.array-intersect]: Argumen开发者_StackOverflow社区t #1 is not an array

Any ideas? Thanks in advance for any help!


$resultset !== $resultSet

You've stored in resultSet, and testested resultset.


Because your are making array with the variable name - $resultSet and passing through array_intersect() is $resultset.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜