  
 
<div style="background-color:#FFF; height:auto;  " align="center">
 
 
  <img id="loder" style="visibility:hidden;"  src="images/ajax-loader.gif" align="middle" alt="Loder" />
 

 
 
 <?php 	include('config/database_connection.php'); 
 
 
 				
 	$display = "";
	$connecttion = getSQLConection();
	
	$query = " SELECT  [pk_id] ";
	$query .= " ,CONVERT(VARCHAR(10), date_time, 7) as [date]   ";
	$query .= " ,right((SELECT convert(varchar, date_time, 100)), 8) as [time]  ";
	$query .= " ,(select country from dbo.tbl_group g WHERE g.pk_id =  [country_id_left]) as left_com ";
	$query .= " ,(select country from dbo.tbl_group g WHERE g.pk_id =  [country_id_right]) as right_com ";
	$query .= " ,Lower(SUBSTRING((select country from dbo.tbl_group g WHERE g.pk_id =  [country_id_left]), 1, 3)) as left_prefix ";
	$query .= " ,Lower(SUBSTRING((select country from dbo.tbl_group g WHERE g.pk_id =  [country_id_right]), 1, 3)) as right_prefix ";
	$query .= " ,[venu],[location], ";
	$query .= " (case isnull(goal_left, -1) When -1 then 'Pending' else 'Complete' end) as status_gol,goal_left, goal_right, ";
	
	$query .= " (select bit_left from dbo.tbl_jackpot p WHERE p.emp_id = $_SESSION[Emp_Id] and group_id = [tbl_fixture_result].pk_id) as bit_left, ";
      
    $query .= " (select bit_right from dbo.tbl_jackpot p WHERE p.emp_id = $_SESSION[Emp_Id] and group_id = [tbl_fixture_result].pk_id) as bit_right, ";
	
	
	  $query .= " isnull((select pk_id from dbo.tbl_jackpot p WHERE p.emp_id = $_SESSION[Emp_Id] and group_id = [tbl_fixture_result].pk_id),0) as bit_tag, ";
	
   $query .= " (case isnull(goal_left, -1) When -1 then -1 else (case
	isnull((select pk_id  from dbo.tbl_jackpot  p WHERE p.emp_id = $_SESSION[Emp_Id] and group_id = [tbl_fixture_result].pk_id and p.bit_left = [tbl_fixture_result].goal_left and   p.bit_right = [tbl_fixture_result].goal_right ), 0)
	when 0 then(case
	isnull((select pk_id  from dbo.tbl_jackpot  p WHERE p.emp_id = $_SESSION[Emp_Id] and group_id = [tbl_fixture_result].pk_id and (p.bit_left > p.bit_right) and ([tbl_fixture_result].goal_left > [tbl_fixture_result].goal_right)), 0)
	When 0 then (case 
	isnull((select pk_id  from dbo.tbl_jackpot  p WHERE p.emp_id = $_SESSION[Emp_Id] and group_id = [tbl_fixture_result].pk_id and (p.bit_left < p.bit_right) and ([tbl_fixture_result].goal_left < [tbl_fixture_result].goal_right)), 0)
	When 0 then 0 else 5 end) else 5 end) else 10 end)end) as point, datediff(MINUTE,(getdate()), date_time) as date_tag, ";
	
	
    $query .= " (SELECT  count(group_id) From [dbo].[viewResult] c WHERE c.group_id = pk_id and point_10 = 10) as point_10 , ";
	$query .= " (SELECT  count(group_id) From [dbo].[viewResult] c WHERE c.group_id = pk_id and point_5 = 5) as point_5, ";
	
	$query .= " (SELECT  count(group_id) From [dbo].[viewResult] c WHERE c.group_id = pk_id and point_0 = 0) as point_0, ";

	$query .= " (SELECT  count(group_id) From dbo.tbl_jackpot c WHERE c.group_id = tbl_fixture_result.pk_id ) as asm_count,  ";
	
		
	    	$query .= "(case round_id When 0 Then 'Qualify Round' When 1 Then '2nd Round' When 2 Then 'Quarter Final Round' 
When 3 Then 'Semi Final Round' else 'Final Round' end) as round_name ";
	   
	$query .= " FROM [db_fifa].[dbo].[tbl_fixture_result] order by round_id desc, pk_id asc ";
 
 
// echo  $query;
 
		$result = sqlsrv_query($connecttion, $query);

		$point  = 0;
		$i = 1;
		$round = '';
		
		while($row = sqlsrv_fetch_array($result))
		{
			if($round != trim($row['round_name']))
			{
				if($i != 1)
				{
					$display .= " <tr><td colspan='15'>&nbsp;</td></tr> </table> ";
				}
			
					 		$display .= "<div style='font-weight:bold; font-size:14px;width:95%; background-color:#000; color:#FFF; height:20px;' align='left'>$row[round_name]</div> <br /> <br />";
							
			     $display .= "<table style='width:95%; height:auto;' cellpadding='0' cellspacing='0' border='0' align='center'>
     
     <thead style='color:#060;'  >
						<th align='center' style='border-bottom:1px solid #000;width:3%;'>&nbsp;SL</th> 
						<th align='center' style='border-bottom:1px solid #000;width:10%;'>Date</th>
						<th align='center' style='border-bottom:1px solid #000;width:10%;'>Time</th>
                        
						<th align='center' style='border-bottom:1px solid #000;width:8%;'></th>
                        <th align='center' style='border-bottom:1px solid #000;width:4%;'>&nbsp;</th>
                        <th align='center' style='border-bottom:1px solid #000;width:3%;'>Match</th>
                        <th align='center' style='border-bottom:1px solid #000;width:8;'></th>
                        <th align='center' style='border-bottom:1px solid #000;width:4%;'>&nbsp;</th>
                        
 
						 
                        <th align='center' style='border-bottom:1px solid #000;width:10%; color:#900;'>Result</th>
 
                        <th align='center' style='border-bottom:1px solid #000;width:10%; color:#060;'>Correct Answers</th>
                        <th align='center' style='border-bottom:1px solid #000;width:10%; color:#666;'>Partial Correct Answers</th>
                        <th align='center' style='border-bottom:1px solid #000;width:10%; color:#F00;'>Wrong Answers</th>
                        <th align='center' style='border-bottom:1px solid #000;width:9%; color:#060;'>Total Contestnents</th>
 
			 
					</thead>";
					
					$round = trim($row['round_name']);
			}
			
			if($row['status_gol'] != 'Pending')
				$display .= "<tr style='height:35px; color:#666; background-color:#666;' >";
			else
				$display .= "<tr style='height:35px; color:#060;background-color:#FFF' >";
	 
			$display .= " 
				<td style='border-bottom:1px solid #000; ' align='left' >
			 	&nbsp;$i.
				</td>
				<td style='border-bottom:1px solid #000;' align='center' >
			 	$row[date]
				</td>
				<td style='border-bottom:1px solid #000;' align='center' >
			    $row[time]
				</td>
				<td style='border-bottom:1px solid #000;' align='left' >
			    $row[left_com]
				</td>
				<td style='border-bottom:1px solid #000;' align='left' >
			    <img class='magnify' width='30' height='18'  align='middle' src='images/country/$row[left_prefix].png' />
				</td>
				<td style='border-bottom:1px solid #000;' align='left' >
			 	VS
				</td>
				<td style='border-bottom:1px solid #000;' align='left' >
			    $row[right_com]
				</td>
				<td style='border-bottom:1px solid #000;' align='left' >
			 	  <img class='magnify' width='30' height='18'  align='middle' src='images/country/$row[right_prefix].png' />
				</td> ";
 
 
				$point = $row['point_0'] - ($row['point_10'] + $row['point_5']);
				
				if($point < 0)
					$point = 0;
 
				$display .= " 
				
			 
 
				
				
				
				<td style='border-bottom:1px solid #000; color:#900;' align='center' >";
				if($row['status_gol'] == 'Pending')
					$display .= "$row[status_gol]";
				else
					$display .= "$row[goal_left] - $row[goal_right]";
			  	 
				$display .= "</td>
				
				
				
			<td style='border-bottom:1px solid #000; color:#900;' align='center' ><a style=' color:#060;' target='_blank' href='index.php?page_id=assumption_result&group_id=$row[pk_id]&point=10'>$row[point_10]</a></td>
			<td style='border-bottom:1px solid #000; color:#900;' align='center' ><a style=' color:#666;' target='_blank' href='index.php?page_id=assumption_result&group_id=$row[pk_id]&point=5'>$row[point_5]</a></td>
			<td style='border-bottom:1px solid #000; color:#900;' align='center' ><a style=' color:#F00;' target='_blank' href='index.php?page_id=assumption_result&group_id=$row[pk_id]&point=0'>$row[point_0]</a></td>
			<td style='border-bottom:1px solid #000; color:#900;' align='center' ><a style=' color:#060;' target='_blank' href='index.php?page_id=biting_result&group_id=$row[pk_id]&type=0'>$row[asm_count]</a></td>

			 
			 
			</tr> ";
			
			$i++;
			
		} 
		
 
	
	
 
 
 
 
 
 echo $display;
 
 ?>

 
      <tr> <td colspan="15">&nbsp;</td></tr>
      
</table>
 

	 