$variable = $_GET['Listing'];

$connection = mysql_connect('localhost', 'root', 'admin');
mysql_query("SET NAMES 'utf8'");
mysql_select_db('WineList'); 
mysqli_set_charset($connection, 'utf8');


 	
       echo "<b><span style='display: inline-block; text-align: left; width:100%; line-height: 200%; font-size: 150%'>".$variable."</span></b>";

     	$sql="SELECT * FROM Wines WHERE QtyInStock>0 AND (Category ='".$variable."' OR Category2 = '".$variable."' OR Category3 ='".$variable."') AND WineType != 'Glass' ORDER BY WinePrice";
      	$records1=mysql_query($sql);
      	
        echo "<table style='width: 100%'>";
        echo "<colgroup>";
        echo "<col span='1' style='width: 85%;'>";
        echo "<col span='1' style='width: 15%;'>";
        echo "</colgroup>";

      	while($wines=mysql_fetch_assoc($records1)){
        	          
          if($wines['WineVintage']==0){
          	
            $vintage=NULL;	
          }
          else{
          	$vintage=$wines['WineVintage'];
          }
            if($wines['QtyInStock'] < 3){  
          $lowStock = "* ";
          }
          else{
          $lowStock = "";
           }  

          if($wines['WineSize']<750){
                $sizeinfo="&nbsp;(small bottle)";
          }
          else{
               $sizeinfo="";
          }
  
         $wineID="<b><a href='http://192.168.104.254/wordpress/single-item/?WineID=".$wines['ID']."&listType=byVarietal&listName=".$variable."&linkCount=1'>".$lowStock.$wines['WineName'].$sizeinfo."&emsp;".$vintage."</a></b>";
echo "<tr>"; 
echo "<td style='text-align: left; vertical-align: bottom; font-size: 1.25em; height: 80%; padding-top: 0px; padding-bottom: 0px; '>".$wineID."</td>";
                 
                $winePrice="<b>$".$wines['WinePrice']."</b>";
                echo "<td style='font-size: 1.25em; text-align: right; vertical-align: bottom; height: 80%; padding-top: 0px; padding-bottom: 0px;'>".$winePrice."</td></tr>"; 
            
               $wineCountry=$wines['WineCountry'].">".$wines['WineRegion'];
                if(substr($wineCountry, strlen($wineCountry)-1,1)==">"){

                       $wineCountry=substr($wineCountry, 0, strlen($wineCountry)-1);
                }
		echo "<tr><td style='text-align: left; vertical-align: top; height: 80%; padding-top: 0px; padding-bottom: 1em; '>".$wineCountry."</td></tr>";
     
        
        }
        echo "</table>";
      	echo "<br><font size='-1'>All prices are in Belize Dollars and include 12.5% GST (Sales Tax). BZ$2 = US$1<font>";
  
