<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
* {
  box-sizing: border-box;
}

input[type=text],[type=date], select, textarea {
  width: 100%;
  padding: 12px;
  border: 1px solid #ccc;
  border-radius: 4px;
  resize: vertical;
}

label {
  padding: 12px 12px 12px 0;
  display: inline-block;
}

input[type=submit] {
  background-color: #4CAF50;
  color: white;
  padding: 12px 20px;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  float: right;
  margin-top:5px;

}

input[type=submit]:hover {
  background-color: #45a049;
}

.ana {
  border-radius: 5px;
  background-color: #f2f2f2;
  padding: 20px;
}

.col-25 {
  float: left;
  width: 25%;
  margin-top: 6px;
}

.col-75 {
  float: left;
  width: 75%;
  margin-top: 6px;
}

/* Clear floats after the columns */
.satir:after {
  content: "";
  display: table;
  clear: both;
  padding:10px;
}

        tr:nth-child(even){background-color: #f2f2f2}

/* Responsive layout - when the screen is less than 600px wide, make the two columns stack on top of each other instead of next to each other */
@media screen and (max-width: 600px) {
  .col-25, .col-75, input[type=submit] {
    width: 100%;
    margin-top: 5px;
  }
  table{
      font-size:0.7em;
  }
}
</style>
</head>
<body>
    <?php include 'menu.php';?>
    <?php include 'baglanti.php';?>

       <form name="form1" method="get" action="">
      <div class="col-75"><label>Ödeme Türü </label></div>
        <div >
          <select name="odemeturu">
                <option>
                <?php      
                if($_GET["odemeturu"]){  // eğer girdi adında bir GET varsa
                $odemeturu = $_GET["odemeturu"];
                echo $odemeturu;
                } else { 
                ?>
                 Tümü
                <?php } ?>
                </option>
          <option value="Aidat">Aidat</option>
          <option value="Kırtasiye">Kırtasiye</option>
          <option value="Robotik">Robotik</option>
          <option value="Tiyatro">Tiyatro</option>
          <option value="Gezi">Gezi</option>
          <option value="Diğer">Diğer</option>
          </select>
              <input type="submit" name="gönder" value="Listele">
              </div>

   </form>
        <div >
        <label>Alt Kategori</label>
        
        
        
        <select name="altkategori">
                  <option value="Tum">Tümü</option>
            <?php



if($_GET["odemeturu"]){  // eğer girdi adında bir GET varsa
$odemeturu = $_GET["odemeturu"];
echo $odemeturu;

        $sorgu = $conn->query("SELECT * FROM gelirbilgi Where anakategori='$odemeturu'");
            
             while ($sonuc = $sorgu->fetch_assoc()) { 
                 ?>
            <option>
                <?php
                $altkategori = $sonuc["altkategori"];
                echo $altkategori; 
                ?>
                </option>
            <?php
            } 


} else {
    $odemeturu = "Tum";
}





            
            
            ?>
           
        </select>
        
        </div>



   <h1 align="center" style="margin-top:50px">Ödeme Listesi</h1>
    <table  style="border-radius: 10px; border: 2px solid #73AD21;">
   
    <tr>
        <td>Öğrenci Adı</td>
        <td>Tarih</td>
        <td>Tutar</td>
        <td>Ödeme Türü</td>
        <td>Alt Kategori</td>
        <td>Bilgi</td>

        <td></td>
    </tr>

<?php 


//veritabanı bağlantısı

$servername = "localhost";
$database = "wwwhepsam_wp745";
$username = "wwwhepsam_wp745";
$password = ")8b9-hS65p";
// Create connection
$conn = mysqli_connect($servername, $username, $password, $database);
// Check connection
if (!$conn) {
    die("Connection failed: " . mysqli_connect_error());
}
mysqli_set_charset($conn, "utf8");
//veritabanı bağlantı bitiş


if($_GET["odemeturu"]){  // eğer girdi adında bir GET varsa
$odemeturu = $_GET["odemeturu"];
echo $odemeturu;
} else {
    $odemeturu = "Tum";
}


        $sorgu = $conn->query("SELECT SUM(tutar) FROM gelir WHERE (ogrenciadi='$i' AND odemeturu='$odemeturu')");


for ($i = 1; $i <= 9; $i++) {//for başlangıç


?>




   
    <tr>
        <td width="60px;"><?php 
        
        $ogrenciadi=$i;
            if ($ogrenciadi=="1"){$ogrenciadi="Atakan G.";
            }
            else if ($ogrenciadi=="2"){$ogrenciadi="Agah Ö.";
            }
            else if ($ogrenciadi=="3"){$ogrenciadi="Eymen G.";
            }
            else if ($ogrenciadi=="4"){$ogrenciadi="Ediz Ç.";
            }
            else if ($ogrenciadi=="5"){$ogrenciadi="Toprak Y.";
            }
            else if ($ogrenciadi=="6"){$ogrenciadi="Ada K.";
            }
            else if ($ogrenciadi=="7"){$ogrenciadi="Ayaz A.";
            }
            else if ($ogrenciadi=="8"){$ogrenciadi="Deniz i.";
            }
            else if ($ogrenciadi=="9"){$ogrenciadi="Sena Ö.";
            }
            else {$ogrenciadi="";} 
        echo   $ogrenciadi;
        
        ?></td>
        <td width="40px;"><?php echo $tarih; ?></td>
        <td>
            <?php                       	    
                                    	    
                $sorgu = $conn->query("SELECT SUM(tutar) FROM gelir WHERE (ogrenciadi='$i' AND odemeturu='$odemeturu')");


            while ($sonuc = $sorgu->fetch_assoc()) { 
                 $tutar = $sonuc['SUM(tutar)'];
            	echo $tutar;
            	echo "<br />";
            }                 

            ?>
        </td>
        <td><?php echo $odemeturu; ?></td>
        <td><?php echo $altkategori; ?></td>
        <td><?php echo $bilgi; ?></td>
    </tr>


<?php 

} //for bitiş


?>


</table>
    <a align="center" href="gelirgiris.php">Yeni Gelir Gir</a>
</body>

<p align="center" style=" padding-top:100px;">Güç İçinde!</p>



</html>