<?php
 $janfam='';
 $sql = mysqli_query($con,"SELECT * FROM farminput where Year='$yr' AND Month='January'");
    $num=mysqli_fetch_array($sql);
    if($num>0)
    {
    $result = mysqli_query($con,"SELECT sum(Amount) FROM farminput where Month ='January' AND Year='$yr'");
    while($row = $result->fetch_assoc()) 
    {
    $janfam=$row['sum(Amount)'];
    }
    }else
    {
    $janfam='0';
    }
    
    //February
    $febfam='';
    
    $sql = mysqli_query($con,"SELECT * FROM farminput where Year='$yr' AND Month='February'");
    $num=mysqli_fetch_array($sql);
    if($num>0)
    {
    $result = mysqli_query($con,"SELECT sum(Amount) FROM farminput where Month ='February' AND Year='$yr'");
    while($row = $result->fetch_assoc()) 
    {
    $febfam=$row['sum(Amount)'];
    }
    }else
    {
    $febfam='0';
    }
    
    //March
    $marfam='';
    
    $sql = mysqli_query($con,"SELECT * FROM farminput where Year='$yr' AND Month='March'");
    $num=mysqli_fetch_array($sql);
    if($num>0)
    {
    $result = mysqli_query($con,"SELECT sum(Amount) FROM farminput where Month ='March' AND Year='$yr'");
    while($row = $result->fetch_assoc()) 
    {
    $marfam=$row['sum(Amount)'];
    }
    }else
    {
    $marfam='0';
    }
    
     //April
    $aprfam='';
    $sql = mysqli_query($con,"SELECT * FROM farminput where Year='$yr' AND Month='April'");
    $num=mysqli_fetch_array($sql);
    if($num>0)
    {
    $result = mysqli_query($con,"SELECT sum(Amount) FROM farminput where Month ='April' AND Year='$yr'");
    while($row = $result->fetch_assoc()) 
    {
    $aprfam=$row['sum(Amount)'];
    }
    }else
    {
    $aprfam='0';
    }
    
    
     //May
    $mayfam='';
    $sql = mysqli_query($con,"SELECT * FROM farminput where Year='$yr' AND Month='May'");
    $num=mysqli_fetch_array($sql);
    if($num>0)
    {
    $result = mysqli_query($con,"SELECT sum(Amount) FROM farminput where Month ='May' AND Year='$yr'");
    while($row = $result->fetch_assoc()) 
    {
    $mayfam=$row['sum(Amount)'];
    }
    }else
    {
    $mayfam='0';
    }
    
    
     //June
    $junfam='';
    $sql = mysqli_query($con,"SELECT * FROM farminput where Year='$yr' AND Month='June'");
    $num=mysqli_fetch_array($sql);
    if($num>0)
    {
    $result = mysqli_query($con,"SELECT sum(Amount) FROM farminput where Month ='June' AND Year='$yr'");
    while($row = $result->fetch_assoc()) 
    {
    $junfam=$row['sum(Amount)'];
    }
    }else
    {
    $junfam='0';
    }
    
    //July
     $julyfam='';
    $sql = mysqli_query($con,"SELECT * FROM farminput where Year='$yr' AND Month='July'");
    $num=mysqli_fetch_array($sql);
    if($num>0)
    {
    $result = mysqli_query($con,"SELECT sum(Amount) FROM farminput where Month ='July' AND Year='$yr'");
    while($row = $result->fetch_assoc()) 
    {
    $julyfam=$row['sum(Amount)'];
    }
    }else
    {
    $julyfam='0';
    }
    
    
    //August
    $augfam='';
    $sql = mysqli_query($con,"SELECT * FROM farminput where Year='$yr' AND Month='August'");
    $num=mysqli_fetch_array($sql);
    if($num>0)
    {
    $result = mysqli_query($con,"SELECT sum(Amount) FROM farminput where Month ='August' AND Year='$yr'");
    while($row = $result->fetch_assoc()) 
    {
    $augfam=$row['sum(Amount)'];
    }
    }else
    {
    $augfam='0';
    }
    
    
    //September
    $sepfam='';
    $sql = mysqli_query($con,"SELECT * FROM farminput where Year='$yr' AND Month='September'");
    $num=mysqli_fetch_array($sql);
    if($num>0)
    {
    $result = mysqli_query($con,"SELECT sum(Amount) FROM farminput where Month ='September' AND Year='$yr'");
    while($row = $result->fetch_assoc()) 
    {
    $sepfam=$row['sum(Amount)'];
    }
    }else
    {
    $sepfam='0';
    }
    
    
    //October
    $octfam='';
    $sql = mysqli_query($con,"SELECT * FROM farminput where Year='$yr' AND Month='October'");
    $num=mysqli_fetch_array($sql);
    if($num>0)
    {
    $result = mysqli_query($con,"SELECT sum(Amount) FROM farminput where Month ='October' AND Year='$yr'");
    while($row = $result->fetch_assoc()) 
    {
    $octfam=$row['sum(Amount)'];
    }
    }else
    {
    $octfam='0';
    }
    
    //November
    $novfam='';
    $sql = mysqli_query($con,"SELECT * FROM farminput where Year='$yr' AND Month='November'");
    $num=mysqli_fetch_array($sql);
    if($num>0)
    {
    $result = mysqli_query($con,"SELECT sum(Amount) FROM farminput where Month ='November' AND Year='$yr'");
    while($row = $result->fetch_assoc()) 
    {
    $novfam=$row['sum(Amount)'];
    }
    }else
    {
    $novfam='0';
    }
    
    
    //December
    $decfam='';
    $sql = mysqli_query($con,"SELECT * FROM farminput where Year='$yr' AND Month='December'");
    $num=mysqli_fetch_array($sql);
    if($num>0)
    {
    $result = mysqli_query($con,"SELECT sum(Amount) FROM farminput where Month ='December' AND Year='$yr'");
    while($row = $result->fetch_assoc()) 
    {
    $decfam=$row['sum(Amount)'];
    }
    }else
    {
    $decfam='0';
    }
 
    ?>