HelixTm adlı üyeden alıntı: mesajı görüntüle
Hocam php mi kullanıyorsun, PDO mu? MYSQL mi? MYSQLi mi? PHP dosyanızı veya php kodlarınızı atın. Yardımcı olayım.




Değişkenlelerle mysql query sorgusu yaptır ve foreach içinden çek veriyi. Eğer pdo kullanıyorsan foreach içine al. Eğer MYSQL kullanıyorsan while içine al. Yazdır.
php ve mysql kullanıyhorum


<?php
include ("header.php");
include ("sidebar.php");
?>
<div class="page-content-wrapper">
  <!-- BEGIN CONTENT BODY -->
  <div class="page-content">
    <div class="row">
      <div class="col-md-12">
        <div class="portlet light bordered">
          <div class="portlet-title">
            <div class="caption">
              <i class="icon-cursor font-dark hide"></i>
              <span class="caption-subject font-dark bold ">Aramaya Göre İstatistikler</span>
            </div>
            <div class="actions">
              <a href="javascript:;" class="btn btn-sm btn-circle red easy-pie-chart-reload">
                <i class="fa fa-repeat"></i> Yenile </a>
              </div>
            </div>
            <div class="portlet-body">
              <div class="row">
                <div class="col-md-4">
                  <div class="easy-pie-chart">
                    <div class="number transactions" data-percent="80">
                      <span class="bold" id="val"> </span> Km </div>
                      <a class="title" > Arama Sonuçlarına <br>Göre Km Toplamı


                      </a>
                    </div>
                  </div>
                  <div class="margin-bottom-10 visible-sm"> </div>
                  <div class="col-md-4">
                    <form action="" method="POST">
 <span class="bold">Tarihe Göre Listeleme</span>
<div><input data-date-format="dd.mm.yyyy" name="tarih1" id="tarih1" class="form-control"  type="date" name="tarih1"></div>
<div><input data-date-format="dd.mm.yyyy" name="tarih2" id="tarih2" class="form-control" type="date"></div><br>
<button type="submit" name="Verileri Listele" class="btn btn red">Verileri Listele</button>
</form>


                    </div>
                    <div class="margin-bottom-10 visible-sm"> </div>
                    <div class="col-md-4">
                     <form action="" method="post">
                      <div class="styled-select slate divim">
                        <select name="filtre">
                          <option>Kayıt Seçiniz...</option>
                          <option value="bugun" selected>Bugün'ün Kayıtları</option>
                          <option value="dun" selected>Dün'ün Kayıtları</option>
                          <option value="hafta">Bu Haftanın Kayıtları</option>
                          <option value="gecenhafta">Geçen Haftanın Kayıtları</option>
                          <option value="ay">Bu Ayın Kayıtları</option>
                          <option value="gecenay">Geçen Ayın Kayıtları</option>
                          <option value="yil">Bu Yılın Kayıtları</option>
                          <option value="tam">Tüm Kayıtlar</option>
                        </select>
                      </div>


                      <button style="margin-left: 20%" type="submit" name="filtrele" class="btn btn-circle red">Filtrele</button>
                    </form>
                  </div>
                </div>
              </div>
            </div>
            <?php if (isset($_POST['filtrele'])) { 
              $tarihim = $_POST['filtre'];


              if ($tarihim == 'bugun') { ?>
              <!-- BEGIN EXAMPLE TABLE PORTLET-->
              <div class="portlet light bordered">
                <div class="portlet-title">
                  <div class="caption font-dark">
                    <i class="icon-settings font-dark"></i>
                    <span id="sdas" class="badge badge-danger"></span>
                  </div>
                  <div class="tools"> </div>
                </div>
                <div class="portlet-body">
                  <table class="table table-striped table-bordered table-hover" id="sample_1">
                    <thead>
                      <tr>
                        <th>id</th>
                        <th>Araç <br> Plakası</th>
                        <th>Çıkış <br>Tarihi</th>
                        <th>İsim <br> Soyisim</th>
                        <th>Çıkış <br>Saati</th>
                        <th>Çıkış <br> Km</th>
                        <th>Gideceği<br> Yer</th>
                        <th>Giriş <br>Saati</th>
                        <th>Giriş<br> Km</th>
                        <th>Geliş <br>Tarihi</th>
                        <th>Km <br>Farkı</th>
                        <th>İşlem</th>


                      </tr>
                    </thead>


                    <tbody>


                      <?php
                      include ("baglan.php");
                      $sorgu=mysql_query("select * from guvenlik where ctarih = CURDATE() ORDER BY id desc");
                      while($dizi=mysql_fetch_array($sorgu))
                      {
                        ?>
                        <tr>


                          <td><?php echo $dizi['id'];?></td>
                          <td><?php echo $dizi['plaka'];?></td>
                          <td><?php
                          $date= strtotime($dizi['ctarih']);
                          $date= date('d.m.Y', $date);
                          echo $date
                          ;?>
                        </td>
                        <td><?php echo $dizi['isimsoyisim'];?></td>
                        <td><?php echo $dizi['csaat'];?></td>
                        <td><?php echo $dizi['ckm'];?></td>
                        <td><?php echo $dizi['gyer'];?></td>
                        <td><?php echo $dizi['gsaat'];?></td>
                        <td><?php echo $dizi['gkm'];?></td>
                        <td><?php
                        $date= strtotime($dizi['gtarih']);
                        $date= date('d.m.Y', $date);
                        echo $date
                        ;?>
                      </td>
                      <td><?php echo $dizi['kmfark'];?></td>
                      <td> <?php echo '<a class="btn btn-circle btn-icon-only btn-default" href="arac_kayit _duzenle.php?id='.$dizi['id'].';"><i class="icon-wrench"></i></a>';?></td>


                    </tr>
                    <?php } ?>                    
                  </tbody>
                </table>
                <script>
                  function hesapla (){
                    var sample_1 = document.getElementById("sample_1"), sumVal = 0;


                    for(var i = 1; i < sample_1.rows.length; i++)
                    {
                      sumVal = sumVal + parseInt(sample_1.rows[i].cells[10].innerHTML);
                    }


                    document.getElementById("val").innerHTML = sumVal;
                    console.log(sumVal);
                  }
                  setInterval("hesapla()", 100);
                </script> 


              </div>
            </div>
            <?php  }elseif ($tarihim == 'dun') { ?>
            <div class="portlet light bordered">
              <div class="portlet-title">
                <div class="caption font-dark">
                  <i class="icon-settings font-dark"></i>
                  <span id="sdas" class="badge badge-danger"></span>
                </div>                    
                <div class="tools"> </div>
              </div>
              <div class="portlet-body">
                <table class="table table-striped table-bordered table-hover" id="sample_1">
                  <thead>
                    <tr>
                      <th>id</th>
                      <th>Araç <br> Plakası</th>
                      <th>Çıkış <br>Tarihi</th>
                      <th>İsim <br> Soyisim</th>
                      <th>Çıkış <br>Saati</th>
                      <th>Çıkış <br> Km</th>
                      <th>Gideceği<br> Yer</th>
                      <th>Giriş <br>Saati</th>
                      <th>Giriş<br> Km</th>
                      <th>Geliş <br>Tarihi</th>
                      <th>Km <br>Farkı</th>
                      <th>İşlem</th>


                    </tr>
                  </thead>


                  <tbody>


                    <?php         
                    include ("baglan.php");
                    $sorgu=mysql_query("select * from guvenlik where ctarih = DATE_SUB(CURDATE(),INTERVAL 1 DAY) ORDER BY id desc");
                    while($dizi=mysql_fetch_array($sorgu))
                    {
                      ?>                      
                      <tr>


                        <td><?php echo $dizi['id'];?></td>
                        <td><?php echo $dizi['plaka'];?></td>
                        <td><?php
                        $date= strtotime($dizi['ctarih']);
                        $date= date('d.m.Y', $date);
                        echo $date
                        ;?>
                      </td>
                      <td><?php echo $dizi['isimsoyisim'];?></td>
                      <td><?php echo $dizi['csaat'];?></td>
                      <td><?php echo $dizi['ckm'];?></td>
                      <td><?php echo $dizi['gyer'];?></td>
                      <td><?php echo $dizi['gsaat'];?></td>
                      <td><?php echo $dizi['gkm'];?></td>
                      <td><?php
                      $date= strtotime($dizi['gtarih']);
                      $date= date('d.m.Y', $date);
                      echo $date
                      ;?>
                    </td>
                    <td><?php echo $dizi['kmfark'];?></td>
                    <td> <?php echo '<a class="btn btn-circle btn-icon-only btn-default" href="arac_kayit _duzenle.php?id='.$dizi['id'].';"><i class="icon-wrench"></i></a>';?></td>


                  </tr>
                  <?php } ?>                    
                </tbody>
              </table>
              <script>
                function hesapla (){
                  var sample_1 = document.getElementById("sample_1"), sumVal = 0;


                  for(var i = 1; i < sample_1.rows.length; i++)
                  {
                    sumVal = sumVal + parseInt(sample_1.rows[i].cells[10].innerHTML);
                  }


                  document.getElementById("val").innerHTML = sumVal;
                  console.log(sumVal);
                }
                setInterval("hesapla()", 100);
              </script> 


            </div>
          </div>
          <?php  }elseif ($tarihim == 'hafta') { ?>
          <div class="portlet light bordered">
            <div class="portlet-title">
              <div class="caption font-dark">
                <i class="icon-settings font-dark"></i>
                <span id="sdas" class="badge badge-danger"></span>
              </div>                    
              <div class="tools"> </div>
            </div>
            <div class="portlet-body">
              <table class="table table-striped table-bordered table-hover" id="sample_1">
                <thead>
                  <tr>
                    <th>id</th>
                    <th>Araç <br> Plakası</th>
                    <th>Çıkış <br>Tarihi</th>
                    <th>İsim <br> Soyisim</th>
                    <th>Çıkış <br>Saati</th>
                    <th>Çıkış <br> Km</th>
                    <th>Gideceği<br> Yer</th>
                    <th>Giriş <br>Saati</th>
                    <th>Giriş<br> Km</th>
                    <th>Geliş <br>Tarihi</th>
                    <th>Km <br>Farkı</th>
                    <th>İşlem</th>


                  </tr>
                </thead>


                <tbody>


                  <?php         
                  include ("baglan.php");
                  $sorgu=mysql_query("select * from guvenlik where WEEK(ctarih) = WEEK(CURDATE()) ORDER BY id desc");
                  while($dizi=mysql_fetch_array($sorgu))
                  {
                    ?>                      
                    <tr>
                      <td><?php echo $dizi['id'];?></td>
                      <td><?php echo $dizi['plaka'];?></td>
                      <td><?php
                      $date= strtotime($dizi['ctarih']);
                      $date= date('d.m.Y', $date);
                      echo $date
                      ;?>
                    </td>
                    <td><?php echo $dizi['isimsoyisim'];?></td>
                    <td><?php echo $dizi['csaat'];?></td>
                    <td><?php echo $dizi['ckm'];?></td>
                    <td><?php echo $dizi['gyer'];?></td>
                    <td><?php echo $dizi['gsaat'];?></td>
                    <td><?php echo $dizi['gkm'];?></td>
                    <td><?php
                    $date= strtotime($dizi['gtarih']);
                    $date= date('d.m.Y', $date);
                    echo $date
                    ;?>
                  </td>
                  <td><?php echo $dizi['kmfark'];?></td>
                  <td> <?php echo '<a class="btn btn-circle btn-icon-only btn-default" href="arac_kayit _duzenle.php?id='.$dizi['id'].';"><i class="icon-wrench"></i></a>';?></td>


                </tr>
                <?php } ?>                    
              </tbody>
            </table>
            <script>
              function hesapla (){
                var sample_1 = document.getElementById("sample_1"), sumVal = 0;


                for(var i = 1; i < sample_1.rows.length; i++)
                {
                  sumVal = sumVal + parseInt(sample_1.rows[i].cells[10].innerHTML);
                }


                document.getElementById("val").innerHTML = sumVal;
                console.log(sumVal);
              }
              setInterval("hesapla()", 100);
            </script> 


          </div>
        </div>
        <?php  }elseif ($tarihim == 'gecenhafta') { ?>
        <div class="portlet light bordered">
          <div class="portlet-title">
            <div class="caption font-dark">
              <i class="icon-settings font-dark"></i>
              <span id="sdas" class="badge badge-danger"></span>
            </div>                    
            <div class="tools"> </div>
          </div>
          <div class="portlet-body">
            <table class="table table-striped table-bordered table-hover" id="sample_1">
              <thead>
                <tr>
                  <th>id</th>
                  <th>Araç <br> Plakası</th>
                  <th>Çıkış <br>Tarihi</th>
                  <th>İsim <br> Soyisim</th>
                  <th>Çıkış <br>Saati</th>
                  <th>Çıkış <br> Km</th>
                  <th>Gideceği<br> Yer</th>
                  <th>Giriş <br>Saati</th>
                  <th>Giriş<br> Km</th>
                  <th>Geliş <br>Tarihi</th>
                  <th>Km <br>Farkı</th>
                  <th>İşlem</th>


                </tr>
              </thead>


              <tbody>


                <?php         
                include ("baglan.php");
                $sorgu=mysql_query("select * from guvenlik where YEARWEEK(ctarih) = YEARWEEK(CURRENT_DATE - INTERVAL 7 DAY) ORDER BY id desc");
                while($dizi=mysql_fetch_array($sorgu))
                {
                  ?>                      
                  <tr>


                    <td><?php echo $dizi['id'];?></td>
                    <td><?php echo $dizi['plaka'];?></td>
                    <td><?php
                    $date= strtotime($dizi['ctarih']);
                    $date= date('d.m.Y', $date);
                    echo $date
                    ;?>
                  </td>
                  <td><?php echo $dizi['isimsoyisim'];?></td>
                  <td><?php echo $dizi['csaat'];?></td>
                  <td><?php echo $dizi['ckm'];?></td>
                  <td><?php echo $dizi['gyer'];?></td>
                  <td><?php echo $dizi['gsaat'];?></td>
                  <td><?php echo $dizi['gkm'];?></td>
                  <td><?php
                  $date= strtotime($dizi['gtarih']);
                  $date= date('d.m.Y', $date);
                  echo $date
                  ;?>
                </td>
                <td><?php echo $dizi['kmfark'];?></td>
                <td> <?php echo '<a class="btn btn-circle btn-icon-only btn-default" href="arac_kayit _duzenle.php?id='.$dizi['id'].';"><i class="icon-wrench"></i></a>';?></td>


              </tr>
              <?php } ?>                    
            </tbody>
          </table>
          <script>
            function hesapla (){
              var sample_1 = document.getElementById("sample_1"), sumVal = 0;


              for(var i = 1; i < sample_1.rows.length; i++)
              {
                sumVal = sumVal + parseInt(sample_1.rows[i].cells[10].innerHTML);
              }


              document.getElementById("val").innerHTML = sumVal;
              console.log(sumVal);
            }
            setInterval("hesapla()", 100);
          </script> 


        </div>
      </div>
      <?php }elseif ($tarihim == 'ay') { ?>


      <div class="portlet light bordered">
        <div class="portlet-title">
          <div class="caption font-dark">
            <i class="icon-settings font-dark"></i>
            <span id="sdas" class="badge badge-danger"></span>
          </div>                    
          <div class="tools"> </div>
        </div>
        <div class="portlet-body">
          <table class="table table-striped table-bordered table-hover" id="sample_1">
            <thead>
              <tr>
                <th>id</th>
                <th>Araç <br> Plakası</th>
                <th>Çıkış <br>Tarihi</th>
                <th>İsim <br> Soyisim</th>
                <th>Çıkış <br>Saati</th>
                <th>Çıkış <br> Km</th>
                <th>Gideceği<br> Yer</th>
                <th>Giriş <br>Saati</th>
                <th>Giriş<br> Km</th>
                <th>Geliş <br>Tarihi</th>
                <th>Km <br>Farkı</th>
                <th>İşlem</th>


              </tr>
            </thead>


            <tbody>


              <?php         
              include ("baglan.php");
              $date= date('m');
              $sorgu=mysql_query("select * from guvenlik where  MONTH(ctarih) = '$date'");
              while($dizi=mysql_fetch_array($sorgu))
              {
                $buyil= date('Y');
                $date= strtotime($dizi['ctarih']);
                $yil= date('Y', $date);
                if ($yil == $buyil) {
                  ?>
                  <tr>
                    <td><?php echo $dizi['id'];?></td>
                    <td><?php echo $dizi['plaka'];?></td>
                    <td><?php
                    $date= strtotime($dizi['ctarih']);
                    $gun= date('d', $date);
                    $ay= date('m', $date);
                    $yil= date('Y', $date);
                    echo $gun.'.'.$ay.'.'.$yil;
                    ?>
                  </td>
                  <td><?php echo $dizi['isimsoyisim'];?></td>
                  <td><?php echo $dizi['csaat'];?></td>
                  <td><?php echo $dizi['ckm'];?></td>
                  <td><?php echo $dizi['gyer'];?></td>
                  <td><?php echo $dizi['gsaat'];?></td>
                  <td><?php echo $dizi['gkm'];?></td>
                  <td><?php
                  $date= strtotime($dizi['gtarih']);
                  $date= date('d.m.Y', $date);
                  echo $date
                  ;?>
                </td>
                <td><?php echo $dizi['kmfark'];?></td>
                <td> <?php echo '<a class="btn btn-circle btn-icon-only btn-default" href="arac_kayit _duzenle.php?id='.$dizi['id'].';"><i class="icon-wrench"></i></a>';?></td>
              </tr>
              <?php } } ?>                    
            </tbody>
          </table>
          <script>
            function hesapla (){
              var sample_1 = document.getElementById("sample_1"), sumVal = 0;


              for(var i = 1; i < sample_1.rows.length; i++)
              {
                sumVal = sumVal + parseInt(sample_1.rows[i].cells[10].innerHTML);
              }


              document.getElementById("val").innerHTML = sumVal;
              console.log(sumVal);
            }
            setInterval("hesapla()", 100);
          </script> 


        </div>
      </div>
      <?php }elseif ($tarihim == 'gecenay') { ?>


      <div class="portlet light bordered">
        <div class="portlet-title">
          <div class="caption font-dark">
            <i class="icon-settings font-dark"></i>
            <span id="sdas" class="badge badge-danger"></span>
          </div>                    
          <div class="tools"> </div>
        </div>
        <div class="portlet-body">
          <table class="table table-striped table-bordered table-hover" id="sample_1">
            <thead>
              <tr>
                <th>id</th>
                <th>Araç <br> Plakası</th>
                <th>Çıkış <br>Tarihi</th>
                <th>İsim <br> Soyisim</th>
                <th>Çıkış <br>Saati</th>
                <th>Çıkış <br> Km</th>
                <th>Gideceği<br> Yer</th>
                <th>Giriş <br>Saati</th>
                <th>Giriş<br> Km</th>
                <th>Geliş <br>Tarihi</th>
                <th>Km <br>Farkı</th>
                <th>İşlem</th>


              </tr>
            </thead>


            <tbody>


              <?php         
              include ("baglan.php");
              $date= date('m');
              $sorgu=mysql_query("select * from guvenlik where  MONTH(ctarih) =  MONTH(CURDATE()-INTERVAL 1 MONTH)");
              while($dizi=mysql_fetch_array($sorgu))
              {
                $buyil= date('Y');
                $date= strtotime($dizi['ctarih']);
                $yil= date('Y', $date);
                if ($yil == $buyil) {
                  ?>
                  <tr>
                    <td><?php echo $dizi['id'];?></td>
                    <td><?php echo $dizi['plaka'];?></td>
                    <td><?php
                    $date= strtotime($dizi['ctarih']);
                    $gun= date('d', $date);
                    $ay= date('m', $date);
                    $yil= date('Y', $date);
                    echo $gun.'.'.$ay.'.'.$yil;
                    ?>
                  </td>
                  <td><?php echo $dizi['isimsoyisim'];?></td>
                  <td><?php echo $dizi['csaat'];?></td>
                  <td><?php echo $dizi['ckm'];?></td>
                  <td><?php echo $dizi['gyer'];?></td>
                  <td><?php echo $dizi['gsaat'];?></td>
                  <td><?php echo $dizi['gkm'];?></td>
                  <td><?php
                  $date= strtotime($dizi['gtarih']);
                  $date= date('d.m.Y', $date);
                  echo $date
                  ;?>
                </td>
                <td><?php echo $dizi['kmfark'];?></td>
                <td> <?php echo '<a class="btn btn-circle btn-icon-only btn-default" href="arac_kayit _duzenle.php?id='.$dizi['id'].';"><i class="icon-wrench"></i></a>';?></td>
              </tr>
              <?php } } ?>                    
            </tbody>
          </table>
          <script>
            function hesapla (){
              var sample_1 = document.getElementById("sample_1"), sumVal = 0;


              for(var i = 1; i < sample_1.rows.length; i++)
              {
                sumVal = sumVal + parseInt(sample_1.rows[i].cells[10].innerHTML);
              }


              document.getElementById("val").innerHTML = sumVal;
              console.log(sumVal);
            }
            setInterval("hesapla()", 100);
          </script> 


        </div>
      </div>0
      <?php }elseif ($tarihim == 'yil') { ?>


      <div class="portlet light bordered">
        <div class="portlet-title">
          <div class="caption font-dark">
            <i class="icon-settings font-dark"></i>
            <span id="sdas" class="badge badge-danger"></span>
          </div>                    
          <div class="tools"> </div>
        </div>
        <div class="portlet-body">
          <table class="table table-striped table-bordered table-hover" id="sample_1">
            <thead>
              <tr>
                <th>id</th>
                <th>Araç <br> Plakası</th>
                <th>Çıkış <br>Tarihi</th>
                <th>İsim <br> Soyisim</th>
                <th>Çıkış <br>Saati</th>
                <th>Çıkış <br> Km</th>
                <th>Gideceği<br> Yer</th>
                <th>Giriş <br>Saati</th>
                <th>Giriş<br> Km</th>
                <th>Geliş <br>Tarihi</th>
                <th>Km <br>Farkı</th>
                <th>İşlem</th>


              </tr>
            </thead>


            <tbody>


              <?php         
              include ("baglan.php");
              $sorgu=mysql_query("select * from guvenlik where ctarih between '2018-01-01' and '2018-12-30' ORDER BY id desc");
              while($dizi=mysql_fetch_array($sorgu))
              {
                ?>                      
                <tr>


                  <td><?php echo $dizi['id'];?></td>
                  <td><?php echo $dizi['plaka'];?></td>
                  <td><?php
                  $date= strtotime($dizi['ctarih']);
                  $date= date('d.m.Y', $date);
                  echo $date
                  ;?>
                </td>
                <td><?php echo $dizi['isimsoyisim'];?></td>
                <td><?php echo $dizi['csaat'];?></td>
                <td><?php echo $dizi['ckm'];?></td>
                <td><?php echo $dizi['gyer'];?></td>
                <td><?php echo $dizi['gsaat'];?></td>
                <td><?php echo $dizi['gkm'];?></td>
                <td><?php
                $date= strtotime($dizi['gtarih']);
                $date= date('d.m.Y', $date);
                echo $date
                ;?>
              </td>
              <td><?php echo $dizi['kmfark'];?></td>
              <td> <?php echo '<a class="btn btn-circle btn-icon-only btn-default" href="arac_kayit _duzenle.php?id='.$dizi['id'].';"><i class="icon-wrench"></i></a>';?></td>


            </tr>
            <?php } ?>                    
          </tbody>
        </table>
        <script>
          function hesapla (){
            var sample_1 = document.getElementById("sample_1"), sumVal = 0;


            for(var i = 1; i < sample_1.rows.length; i++)
            {
              sumVal = sumVal + parseInt(sample_1.rows[i].cells[10].innerHTML);
            }


            document.getElementById("val").innerHTML = sumVal;
            console.log(sumVal);
          }
          setInterval("hesapla()", 100);
        </script> 


      </div>
    </div>
    <?php }elseif ($tarihim == 'gecenay') { ?>
    <div class="portlet light bordered">
      <div class="portlet-title">
        <div class="caption font-dark">
          <i class="icon-settings font-dark"></i>
          <span id="sdas" class="badge badge-danger"></span>
        </div>                    
        <div class="tools"> </div>
      </div>
      <div class="portlet-body">
        <table class="table table-striped table-bordered table-hover" id="sample_1">
          <thead>
            <tr>
              <th>id</th>
              <th>Araç <br> Plakası</th>
              <th>Çıkış <br>Tarihi</th>
              <th>İsim <br> Soyisim</th>
              <th>Çıkış <br>Saati</th>
              <th>Çıkış <br> Km</th>
              <th>Gideceği<br> Yer</th>
              <th>Giriş <br>Saati</th>
              <th>Giriş<br> Km</th>
              <th>Geliş <br>Tarihi</th>
              <th>Km <br>Farkı</th>
              <th>İşlem</th>


            </tr>
          </thead>


          <tbody>


            <?php         
            include ("baglan.php");
            $sorgu=mysql_query("select * from guvenlik");
            while($dizi=mysql_fetch_array($sorgu))
            {
              $buay= date('m');
              $buayim= $buay-'1';
              $buyil= date('Y');
              $date= strtotime($dizi['ctarih']);
              $yil= date('Y', $date);
              $ay= date('m', $date);
              if ($yil == $buyil) {
                if ($ay == $buayim) {
                  ?>
                  <tr>


                    <td><?php echo $dizi['id'];?></td>
                    <td><?php echo $dizi['plaka'];?></td>
                    <td><?php
                    $date= strtotime($dizi['ctarih']);
                    $date= date('d.m.Y', $date);
                    echo $date
                    ;?>
                  </td>
                  <td><?php echo $dizi['isimsoyisim'];?></td>
                  <td><?php echo $dizi['csaat'];?></td>
                  <td><?php echo $dizi['ckm'];?></td>
                  <td><?php echo $dizi['gyer'];?></td>
                  <td><?php echo $dizi['gsaat'];?></td>
                  <td><?php echo $dizi['gkm'];?></td>
                  <td><?php
                  $date= strtotime($dizi['gtarih']);
                  $date= date('d.m.Y', $date);
                  echo $date
                  ;?>
                </td>
                <td><?php echo $dizi['kmfark'];?></td>
                <td> <?php echo '<a class="btn btn-circle btn-icon-only btn-default" href="arac_kayit _duzenle.php?id='.$dizi['id'].';"><i class="icon-wrench"></i></a>';?></td>


              </tr>
              <?php } } }?>                    
            </tbody>
          </table>
          <script>
            function hesapla (){
              var sample_1 = document.getElementById("sample_1"), sumVal = 0;


              for(var i = 1; i < sample_1.rows.length; i++)
              {
                sumVal = sumVal + parseInt(sample_1.rows[i].cells[10].innerHTML);
              }


              document.getElementById("val").innerHTML = sumVal;
              console.log(sumVal);
            }
            setInterval("hesapla()", 100);
          </script> 


        </div>
      </div>
      <?php }elseif ($tarihim == 'tam') { ?>


      <div class="portlet light bordered">
        <div class="portlet-title">
          <div class="caption font-dark">
            <i class="icon-settings font-dark"></i>
            <span id="sdas" class="badge badge-danger"></span>
          </div>                    
          <div class="tools"> </div>
        </div>
        <div class="portlet-body">
          <table class="table table-striped table-bordered table-hover" id="sample_1">
            <thead>
              <tr>
                <th>id</th>
                <th>Araç <br> Plakası</th>
                <th>Çıkış <br>Tarihi</th>
                <th>İsim <br> Soyisim</th>
                <th>Çıkış <br>Saati</th>
                <th>Çıkış <br> Km</th>
                <th>Gideceği<br> Yer</th>
                <th>Giriş <br>Saati</th>
                <th>Giriş<br> Km</th>
                <th>Geliş <br>Tarihi</th>
                <th>Km <br>Farkı</th>
                <th>İşlem</th>


              </tr>
            </thead>


            <tbody>


              <?php         
              include ("baglan.php");           
              $sorgu=mysql_query("select * from guvenlik where ctarih between  '2018-01-01' and '2018-12-31' ORDER BY id desc");
              while($dizi=mysql_fetch_array($sorgu))
              {
                ?>                      
                <tr>


                  <td><?php echo $dizi['id'];?></td>
                  <td><?php echo $dizi['plaka'];?></td>
                  <td><?php
                  $date= strtotime($dizi['ctarih']);
                  $date= date('d.m.Y', $date);
                  echo $date
                  ;?>
                </td>
                <td><?php echo $dizi['isimsoyisim'];?></td>
                <td><?php echo $dizi['csaat'];?></td>
                <td><?php echo $dizi['ckm'];?></td>
                <td><?php echo $dizi['gyer'];?></td>
                <td><?php echo $dizi['gsaat'];?></td>
                <td><?php echo $dizi['gkm'];?></td>
                <td><?php
                $date= strtotime($dizi['gtarih']);
                $date= date('d.m.Y', $date);
                echo $date
                ;?>
              </td>
              <td><?php echo $dizi['kmfark'];?></td>
              <td> <?php echo '<a class="btn btn-circle btn-icon-only btn-default" href="arac_kayit _duzenle.php?id='.$dizi['id'].';"><i class="icon-wrench"></i></a>';?></td>


            </tr>
            <?php } ?>                    
          </tbody>
        </table>
        <script>
          function hesapla (){
            var sample_1 = document.getElementById("sample_1"), sumVal = 0;


            for(var i = 1; i < sample_1.rows.length; i++)
            {
              sumVal = sumVal + parseInt(sample_1.rows[i].cells[10].innerHTML);
            }


            document.getElementById("val").innerHTML = sumVal;
            console.log(sumVal);
          }
          setInterval("hesapla()", 100);
        </script> 


      </div>
    </div>
    <?php } }elseif (!isset($_POST['filtrele'])) { ?>


    <div class="portlet light bordered">
      <div class="portlet-title">
        <div class="caption font-dark">
          <i class="icon-settings font-dark"></i>
          <span id="sdas" class="badge badge-danger"></span>
        </div>                    
        <div class="tools"> </div>
      </div>
      <div class="portlet-body">
        <table class="table table-striped table-bordered table-hover" id="sample_1">
          <thead>
            <tr>
              <th>id</th>
              <th>Araç <br> Plakası</th>
              <th>Çıkış <br>Tarihi</th>
              <th>İsim <br> Soyisim</th>
              <th>Çıkış <br>Saati</th>
              <th>Çıkış <br> Km</th>
              <th>Gideceği<br> Yer</th>
              <th>Giriş <br>Saati</th>
              <th>Giriş<br> Km</th>
              <th>Geliş <br>Tarihi</th>
              <th class="warning" >Km <br>Farkı</th>
              <th>İşlem</th>


            </tr>
          </thead>


          <tbody>


            <?php         
            include ("baglan.php");           
            $sorgu=mysql_query("select * from guvenlik where ctarih between  '2018-01-01' and '2018-12-31' ORDER BY id desc");
            while($dizi=mysql_fetch_array($sorgu))
            {
              ?>                      
              <tr>


                <td><?php echo $dizi['id'];?></td>
                <td><?php echo $dizi['plaka'];?></td>
                <td><?php
                $date= strtotime($dizi['ctarih']);
                $date= date('d.m.Y', $date);
                echo $date
                ;?>
              </td>
              <td><?php echo $dizi['isimsoyisim'];?></td>
              <td><?php echo $dizi['csaat'];?></td>
              <td><?php echo $dizi['ckm'];?></td>
              <td><?php echo $dizi['gyer'];?></td>
              <td><?php echo $dizi['gsaat'];?></td>
              <td><?php echo $dizi['gkm'];?></td>
              <td><?php
              $date= strtotime($dizi['gtarih']);
              $date= date('d.m.Y', $date);
              echo $date
              ;?>
            </td>
            <td class="warning" ><?php echo $dizi['kmfark'];?></td>
            <td> <?php echo '<a class="btn btn-circle btn-icon-only btn-default" href="arac_kayit _duzenle.php?id='.$dizi['id'].';"><i class="icon-wrench"></i></a>';?></td>


          </tr>
          <?php } ?>                    
        </tbody>
      </table>
      <script>
        function hesapla (){
          var sample_1 = document.getElementById("sample_1"), sumVal = 0;


          for(var i = 1; i < sample_1.rows.length; i++)
          {
            sumVal = sumVal + parseInt(sample_1.rows[i].cells[10].innerHTML);
          }


          document.getElementById("val").innerHTML = sumVal;
          console.log(sumVal);
        }
        setInterval("hesapla()", 100);
      </script> 


    </div>
  </div>
  <?php } ?>




</div>
</div>
<!-- END CONTENT BODY -->
</div>
<?php
include "footer.php";
?>