<?php

if(!$_POST){
  echo '<meta http-equiv="refresh" content="0;URL=index.php">';
}


$_title         =  $_POST['ara'];

?>
<div class="container-fluid adres_cubugu">
  <div class="row">
  	<div class="container">
  		<div class="row">
  			<div class="col-md-12">
  				<ul>
  					<li><a href="index.php"><i class="fa fa-home"></i> Anasayfa</a> <span><i class="fa fa-arrow-right"></i></span></li>
  					<li><a href="#"><?php echo $_POST['ara']; ?></a></li>
  				</ul>
  			</div>
  		</div>
  	</div>
  </div>
</div>

<section class="bg-dis">
	<div class="container">
		<div class="row mt-15 mb-15">

      <div class="col-md-9">
        <div class="row">

          <?php

          $query = $db->query("SELECT * FROM urun WHERE baslik LIKE '%{$_POST['ara']}%'", PDO::FETCH_ASSOC);
          if($query->rowCount()){
              foreach($query as $row){
                $img1 = $db->query("SELECT * FROM urun_img WHERE urun_id = '{$row['id']}' LIMIT 0,1")->fetch(PDO::FETCH_ASSOC);
                $img2 = $db->query("SELECT * FROM urun_img WHERE urun_id = '{$row['id']}' LIMIT 1,1")->fetch(PDO::FETCH_ASSOC);
                if(!$img2){
                  $img2['img'] = $img1['img'];
                }
          ?>
          <div class="col-md-3 mb-15 col-xs-6">
            <a href="urun/<?php echo $row['sef']; ?>" title="<?php echo $row['baslik']; ?>" class="urun">
              <img src="upload/<?php echo $img1['img']; ?>" alt="<?php echo $row['baslik']; ?>" class="img-responsive img1">
              <img src="upload/<?php echo $img2['img']; ?>" alt="<?php echo $row['baslik']; ?>" class="img-responsive img2">
              <b><?php echo $row['baslik']; ?></b>
              <div>
                  <span><?php echo $row['fiyat']; ?> TL</span>
                  <span><?php echo !empty($row['eski_fiyat']) ? $row['eski_fiyat'].' TL' : ''; ?></span>
              </div>
            </a>
          </div>
          <?php 
            } 
          }else{
            echo '<div class="col-md-12"><h3>Ürün Bulunamadı...</h3></div>';
          }
          ?>
        </div>



      </div>

    </div>
  </div>
</section>

