<?php
 $janexpe='';
 $sql = mysqli_query($con,"SELECT * FROM Expenses where Year='$yr' AND Month='January'");
    $num=mysqli_fetch_array($sql);
    if($num>0)
    {
    $result = mysqli_query($con,"SELECT sum(Amount) FROM Expenses where Month ='January' AND Year='$yr'");
    while($row = $result->fetch_assoc()) 
    {
    $janexpe=$row['sum(Amount)'];
    }
    }else
    {
    $janexpe='0';
    }
    
    //February
    $febexpe='';
    
    $sql = mysqli_query($con,"SELECT * FROM Expenses where Year='$yr' AND Month='February'");
    $num=mysqli_fetch_array($sql);
    if($num>0)
    {
    $result = mysqli_query($con,"SELECT sum(Amount) FROM Expenses where Month ='February' AND Year='$yr'");
    while($row = $result->fetch_assoc()) 
    {
    $febexpe=$row['sum(Amount)'];
    }
    }else
    {
    $febexpe='0';
    }
    
    //March
    $marexpe='';
    
    $sql = mysqli_query($con,"SELECT * FROM Expenses where Year='$yr' AND Month='March'");
    $num=mysqli_fetch_array($sql);
    if($num>0)
    {
    $result = mysqli_query($con,"SELECT sum(Amount) FROM Expenses where Month ='March' AND Year='$yr'");
    while($row = $result->fetch_assoc()) 
    {
    $marexpe=$row['sum(Amount)'];
    }
    }else
    {
    $marexpe='0';
    }
    
     //April
    $aprexpense='';
    
    $sql = mysqli_query($con,"SELECT * FROM Expenses where Year='$yr' AND Month='April'");
    $num=mysqli_fetch_array($sql);
    if($num>0)
    {
    $result = mysqli_query($con,"SELECT sum(Amount) as ama FROM Expenses where Month ='April' AND Year='$yr'");
    while($row = $result->fetch_assoc()) 
    {
    $aprexpense=$row['ama'];
    }
    }else
    {
    $aprexpense='0';
    }
    
     //May
    $mayexpe='';
    
    $sql = mysqli_query($con,"SELECT * FROM Expenses where Year='$yr' AND Month='May'");
    $num=mysqli_fetch_array($sql);
    if($num>0)
    {
    $result = mysqli_query($con,"SELECT sum(Amount) FROM Expenses where Month ='May' AND Year='$yr'");
    while($row = $result->fetch_assoc()) 
    {
    $mayexpe=$row['sum(Amount)'];
    }
    }else
    {
    $mayexpe='0';
    }
 
       //June
    $junexpe='';
    
    $sql = mysqli_query($con,"SELECT * FROM Expenses where Year='$yr' AND Month='June'");
    $num=mysqli_fetch_array($sql);
    if($num>0)
    {
    $result = mysqli_query($con,"SELECT sum(Amount) FROM Expenses where Month ='June' AND Year='$yr'");
    while($row = $result->fetch_assoc()) 
    {
    $junexpe=$row['sum(Amount)'];
    }
    }else
    {
    $junexpe='0';
    }
    
     //July
    $julyexpe='';
    
    $sql = mysqli_query($con,"SELECT * FROM Expenses where Year='$yr' AND Month='July'");
    $num=mysqli_fetch_array($sql);
    if($num>0)
    {
    $result = mysqli_query($con,"SELECT sum(Amount) FROM Expenses where Month ='July' AND Year='$yr'");
    while($row = $result->fetch_assoc()) 
    {
    $julyexpe=$row['sum(Amount)'];
    }
    }else
    {
    $julyexpe='0';
    }
    
    
     //August
    $augexpe='';
    
    $sql = mysqli_query($con,"SELECT * FROM Expenses where Year='$yr' AND Month='August'");
    $num=mysqli_fetch_array($sql);
    if($num>0)
    {
    $result = mysqli_query($con,"SELECT sum(Amount) FROM Expenses where Month ='August' AND Year='$yr'");
    while($row = $result->fetch_assoc()) 
    {
    $augexpe=$row['sum(Amount)'];
    }
    }else
    {
    $augexpe='0';
    }
    
    
    //September
    $sepexpe='';
    
    $sql = mysqli_query($con,"SELECT * FROM Expenses where Year='$yr' AND Month='September'");
    $num=mysqli_fetch_array($sql);
    if($num>0)
    {
    $result = mysqli_query($con,"SELECT sum(Amount) FROM Expenses where Month ='September' AND Year='$yr'");
    while($row = $result->fetch_assoc()) 
    {
    $sepexpe=$row['sum(Amount)'];
    }
    }else
    {
    $sepexpe='0';
    }
    
    
    //October
    $octexpe='';
    
    $sql = mysqli_query($con,"SELECT * FROM Expenses where Year='$yr' AND Month='October'");
    $num=mysqli_fetch_array($sql);
    if($num>0)
    {
    $result = mysqli_query($con,"SELECT sum(Amount) FROM Expenses where Month ='October' AND Year='$yr'");
    while($row = $result->fetch_assoc()) 
    {
    $octexpe=$row['sum(Amount)'];
    }
    }else
    {
    $octexpe='0';
    }
    
    
    //November
    $novexpe='';
    
    $sql = mysqli_query($con,"SELECT * FROM Expenses where Year='$yr' AND Month='November'");
    $num=mysqli_fetch_array($sql);
    if($num>0)
    {
    $result = mysqli_query($con,"SELECT sum(Amount) FROM Expenses where Month ='November' AND Year='$yr'");
    while($row = $result->fetch_assoc()) 
    {
    $novexpe=$row['sum(Amount)'];
    }
    }else
    {
    $novexpe='0';
    }
    
    
    
    //December
    $decexpe='';
    
    $sql = mysqli_query($con,"SELECT * FROM Expenses where Year='$yr' AND Month='December'");
    $num=mysqli_fetch_array($sql);
    if($num>0)
    {
    $result = mysqli_query($con,"SELECT sum(Amount) FROM Expenses where Month ='December' AND Year='$yr'");
    while($row = $result->fetch_assoc()) 
    {
    $decexpe=$row['sum(Amount)'];
    }
    }else
    {
    $decexpe='0';
    }
    
    ?>