$variable = $_GET['WineType'];

$connection = mysql_connect('localhost', 'root', 'admin');

mysql_select_db('WineList'); 
mysqli_set_charset($connection, 'utf8');

	$sql="SELECT DISTINCT Category FROM Wines WHERE WineType='".$variable."' ORDER BY Category"; 
	$records=mysql_query($sql);
    
	while($winecategory=mysql_fetch_assoc($records)){	
      
      	echo "<TABLE Width=100% BORDER=0 CELLPADDING=0 CELLSPACING=0>";
      
    	echo "<tr><td valign='bottom' height='20'><h2><b>".$winecategory['Category']."</b></h2></td></tr>";
      
     	$sql="SELECT * FROM Wines WHERE Category='".$winecategory['Category']."' AND WineType='".$variable."'";
      	$records1=mysql_query($sql);
      	
      	while($wines=mysql_fetch_assoc($records1)){
        
        	echo "<tr>";
          
          if($wines['WineVintage']==0){
          	
            $vintage=NULL;
          	
          }
          else{
          	$vintage=$wines['WineVintage'];
          }
          
			$wineID = "<td><b><a href='http://192.168.104.254/wordpress/single-item/?WineID=".$wines['ID']."'>".$wines['WineName']."</a> &emsp;".$vintage."</b></td>";
            
          	echo $wineID;
          
    		echo "<td align='right'><b>"."$".$wines['WinePrice']."</b></td>";
  			echo "</tr>";
  			echo "<tr>";
  			echo "<td valign='top' height='15'>".$wines['WineCountry'].">".$wines['WineRegion']."</td>";
			echo "</tr>";	
        
        }
      	echo "</TABLE>";
    }

    
