 
<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 TOP 1000 [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 round_id When 0 Then 'Qualify Round' When 1 Then '2nd Round' When 2 Then 'Quarter Final Round' 
When 3 Then 'Semi Final Round' When 4 then 'Play-off for third place' else 'Final Round' end) as round_name ";
	
	$query .= " FROM [db_fifa].[dbo].[tbl_fixture_result] ";
 
 
 
		$result = sqlsrv_query($connecttion, $query);


 		$i = 1;
		
		$round = '';
		
		while($row = sqlsrv_fetch_array($result))
		{
			if($round != trim($row['round_name']))
			{
				if($i != 1)
				{
					$display .= " <tr><td colspan='10'>&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='left' style='border-bottom:1px solid #000;width:5%;'>&nbsp;SL</th> 
						<th  align='left' style='border-bottom:1px solid #000;width:10%;'>Date</th>
						<th  align='left' style='border-bottom:1px solid #000;width:10%;'>Time</th>
						<th  align='left' style='border-bottom:1px solid #000;width:10%;'></th>
                        <th style='border-bottom:1px solid #000;width:5%;'>&nbsp;</th>
                        <th style='border-bottom:1px solid #000;width:5%;'>Mathch</th>
                        <th style='border-bottom:1px solid #000;width:10%;'>&nbsp;</th>
                        <th style='border-bottom:1px solid #000;width:5%;'>&nbsp;</th>
	<th align='left' style='border-bottom:1px solid #000;width:20%;'>Location</th>
						<th align='left' style='border-bottom:1px solid #000;width:20%;'>Venu</th>
					
 
			 
					</thead> ";
					
					$round = trim($row['round_name']);
			}
 
			
		 
			
			$display .= "<tr style='height:35px; color:#060;' >
				<td style='border-bottom:1px solid #000; ' align='left' >
			 	&nbsp;$i
				</td>
				<td style='border-bottom:1px solid #000;' align='left' >
			 	$row[date]
				</td>
				<td style='border-bottom:1px solid #000;' align='left' >
			    $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>
				<td style='border-bottom:1px solid #000;' align='left' >
			 	$row[venu]
				</td>
				<td style='border-bottom:1px solid #000;' align='left' >
			 	$row[location]
				</td>
			 
			</tr> ";
			
			$i++;
			
		} 
		
	$display .= " <tr><td colspan='10'>&nbsp;</td></tr> </table> ";
 
  echo $display; 
  
  ?>
 
 



	 