I have a chess website and there's a mygames section which, as you would expect lists users games. At the end of the game, it shows up still, but let's you see the status (who won, who lost). Once the game is over, it also shows an "archive game" link. This is where I'm having issues, surprisingly.
So I have a game table with a number of fields, including player_white and player_black. So on the mygames page, I pull up all current games for a user with
PHP Code:
select
*
from
game
where
player_white='{$sUser}'
or
player_black='{$sUser}'
Now, the archiving part. I can, on the same game table, have fields like
player_white_archive and
player_black_archive. Initially, it would be set to null and when the person archives their game, set either one of these fields to 1 (or whatever) to indicate they've archived the game. The only problem with this is that for every game, the player can either be white or black. It's easy enough to figure out for a particular game, "Ok, for this game you were black, so set player_black_archive to 1. However, what sql do you use to pull up all games that have not been archived? For each game, you can be either white or black. If I knew that for every game you'd be white, for example, I could do
PHP Code:
select
*
from
game
where
player_white='{$sUser}'
and
player_white_archive is null
But in some games you can be white and in others black. I've tried a separate archived_games table which has the user (either player_white or player_black) and the game id, but this approach and using a left join statement seems to cause just as many headaches. Anybody have thoughts on what I should do? Thanks in advance