<!doctype html>
<html>
<head><meta http-equiv="Content-Type" content="text/html; charset=utf-8">

<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Yemek Bilgi Giriş</title>

<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;
}

/* 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;
  }
}
</style>

</head>

<body>
    <?php include 'menu.php';?>
    <?php include 'baglanti.php';?>
<div class="ana">
<h1 align="center">Yoklama</h1>
<br>

    <?php
    
    //sınıf bilgisi çekme alanı başlangıç
    if($_GET["sinif"]){ 
    $sinif = $_GET["sinif"]; // GET değerini değişkene aktarıyoruz
         $sorgu = $conn->query("SELECT * FROM ogrenci WHERE sinif='$sinif' AND durum='Aktif' "); 
         ?>
         
    <form action="yoklamakayit.php"  method="POST">
    <input type="date" value="<?php echo date('Y-m-d'); ?>" name="tarih"><br><br>  
    
    <?
        //kayıt sayfasına sıralı veri girişi için gerekli alan    
        $i=0;   
            
        // $sorgu = $conn->query("SELECT * FROM ogrenci WHERE sinif='$sinif' "); üst kısımda if içerisine yerleştirildi
                while ($sonuc = $sorgu->fetch_assoc()) { 
                $ogrenciadi = $sonuc['ogrenciadi']; 
                $id = $sonuc['id']; 
                $i=$i+1;
                //echo "<br>Öğrenci İsimleri: ";
                

                ?>
                <div class="satir">
                <input type="text" value="<?php echo $ogrenciadi; ?>" name="<?php echo $i; ?>" readonly>
                
                <select name="<?php echo $i."yoklama"; ?>" id="yoklama">
                  <option value="1">Geldi</option>
                  <option value="0">Gelmedi</option>
                </select>
                <br><br>
                </div>
    <?php 
                }
    ?>
                <input type="text" value="<?php echo $i; ?>" name= "ogrencisayisi" readonly>
                <input type="text" value="<?php echo $sinif; ?>" name= "sinif" readonly>
               <input type="submit" value="Kaydet">
    </form>

         <?php
    } else {?>
        
            <form action=""  method="GET">

        <div class="satir">
    <?php include 'sinif.php'; //sınıfların listesini alma ?>
              <br>
              <input type="submit" value="Sınıftaki Öğrencileri Getir">
              </div>
    </form>
        <?php 
    }
    ?>
    

  
 </div>    

    
    

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

</body>
</html>
