<?php

define('_IN_JOHNCMS', 1);
$textl = 'O\'yinlar tarixi';
$rootpath = '../../';
require_once ('../../incfiles/core.php');
require_once ('../../incfiles/head.php');
if (!$user_id)
    {
       $error = $lng['access_guest_forbidden'];
       echo functions::display_error($error, '<a href="/index.php">' . $lng['back'] . '</a>');
       require_once ('../../incfiles/end.php');
       exit();
       
    }
$id = abs(intval($_GET['id']));
if (!$id)
    {
       $error = 'XATO!';
       echo functions::display_error($error, '<a href="game.php">' . $lng['back'] . '</a>');
       require_once ('../incfiles/end.php');
       exit(); 
    }
$res1=mysql_fetch_assoc(mysql_query("select `name` from `users` where `id`='".$id."'"));
?>
<div class="phdr" style="text-align:center;">O'yinlar tarixi</div>
<table class="table"  width="100%" border="0" cellspacing="1" cellpadding="4">
    
    <tr height="200%" class="un_title">
        
            <td width="2%" align="center">№</td>
            
            <td width="20%" align="center">Qatnashuvchilar</td>
            <td width="5%" align="center">Stavka</td>
            <td width="5%" align="center">Tanlov</td>
            <td width="5%" align="center">Natija</td>
    </tr>  

<?php 
$i=1;
$sql = mysql_query("select * from `knb_games` where (`create_user_id`='". $id ."' or `opponent_user_id`='". $id ."') and `opponent_user_id`<>'0'");
while($res=mysql_fetch_assoc($sql))
{
    echo $i % 2 ? '<tr class="list2">' : '<tr class="list1">';
    ?>
       
        
            <td width="2%"  align="center"><?php echo $i; ?></td>
            <td width="20%" align="center"><?php echo $res['create_user_name'] ?><br /><?php echo $res['opponent_user_name'] ?></td>
            <td width="4%" align="center"><?php echo $res['stavka']; ?></td>
            <td  width="5%" align="center"><?php echo $res['choice'] ?><br /> <?php echo $res['opponent_choice'] ?></td>
                <?php
                $ishod = '';
                    if (($res['opponent_choice']=='Tosh') && ($res['choice'])=='Tosh') $ishod='Durrang';
                    if (($res['opponent_choice']=='Tosh') && ($res['choice'])=='Qaychi')$ishod=$res['opponent_user_name'];
                    if (($res['opponent_choice']=='Tosh') && ($res['choice'])=='Qog`oz') $ishod=$res['create_user_name'];
                    
                    if (($res['opponent_choice']=='Qaychi') && ($res['choice'])=='Tosh') $ishod=$res['create_user_name'];
                    if (($res['opponent_choice']=='Qaychi') && ($res['choice'])=='Qaychi') $ishod='Durrang';
                    if (($res['opponent_choice']=='Qaychi') && ($res['choice'])=='Qog`oz') $ishod=$res['opponent_user_name'];
                    
                    if (($res['opponent_choice']=='Qog`oz') && ($res['choice'])=='Tosh') $ishod=$res['opponent_user_name'];
                    if (($res['opponent_choice']=='Qog`oz') && ($res['choice'])=='Qaychi') $ishod=$res['create_user_name'];
                    if (($res['opponent_choice']=='Qog`oz') && ($res['choice'])=='Qog`oz') $ishod='Durrang';
                 $i % 2 ? $class='list2' : $class='list1';   
                if ($ishod==$res1['name']) $class = 'gmenu'; 
                    elseif($ishod!='Durrang') $class = 'rmenu';
                ?>
                
            <td class="<?php echo $class; ?>" width="5%" align="center"><?php echo $ishod; ?></td>
       </tr>
    <?php
    $i++;
}
?>
</table>
<?php
require_once ('../../incfiles/end.php');