v2.5.2
Giriş yap

Bootstrap Modal Kullanım Hatası

ynscnr55
997 defa görüntülendi

Merhabalar. Veritabanından veri silme işleminden önce modal ile kullanıcıya uyarı verdiriyorum. Silme işlemi de başarılı olarak gerçekleşiyor fakat sorun şu modal içinde kullandığım php kodu hep sabit id çekiyor.

    <div class="modal fade" tabindex="-1" role="dialog" id="ornekModal">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
        <h4 class="modal-title">Silmek İstediğinize Emin Misiniz?</h4>
      </div>
      <div class="modal-body">
        <p>Yapılan silme işlemi geri alınamaz!!</p>
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-default" data-dismiss="modal">Kapat</button>
		<a href="menu_sil.php?menu_id=<?php echo $menuCek['menu_id'] ?>"><button class="btn btn-danger"><i class="glyphicon glyphicon-trash"></i> Sil</button></a>
		
      </div>
    </div><!-- /.modal-content -->
  </div><!-- /.modal-dialog -->
</div><!-- /.modal -->

modal kodlarım burası. menu_id sabit bir id çekiyor düzeltemedim. Yardımcı olur musunuz?

ynscnr55
970 gün önce

menu_sil.php Kodlarımı ilettim.

    <html>
<head>
<title></title>
</head>

<body>
 <?php
include '../db/baglanti.php';

if(isset($_GET['menu_id']))
{
    echo $id=$_GET['menu_id'];
	
	die();
    $menuSil=$db->prepare("delete from menuler where menu_id=:id");
	
    $menuSil->execute(array("id"=>$id));
    if($menuSil)
    {
        echo '<script type="text/javascript" src="js/sweetalert2.all.min.js"></script>';
		echo "<script>Swal.fire( {title:'Başarılı', text:'Menü Silindi.', icon:'success', confirmButtonText:'Tamam'}).then((value)=> {
			if(value.isConfirmed){window.location.href='../production/menu.php'}}) </script>";
    }
    else
    {
        echo '<script type="text/javascript" src="js/sweetalert2.all.min.js"></script>';
		echo "<script>Swal.fire( {title:'Başarısız', text:'Menü Silinenemedi.', icon:'error', confirmButtonText:'Tamam'}).then((value)=> {
			if(value.isConfirmed){window.location.href='../production/menu.php'}})</script>";


    }
}

?>

</body>
</html>

bu da menu.php kodlarım

<?php
include 'header.php';
if(isset($_POST['arama']))
{
    $aranan=$_POST['aranan'];
  $menusor=$db->prepare("select * from menuler where menu_ad like '$aranan'");
    $menusor->execute();
}
else{
    $menusor=$db->prepare("select * from menuler  where menu_ust=:menu_ust order by menu_sira asc");
    $menusor->execute(array("menu_ust"=>'0'));
    //$iceriksor=$db->query("select * from icerik")->fetchAll();
}
?>


        <!-- page content -->
        <div class="right_col" role="main">
          <div class="">
            <div class="page-title">

            </div>
              <div class="title_right">
                  <div class="col-md-5 col-sm-5 col-xs-12 form-group pull-right top_search">

                     <form action="" method="post">
                      <div class="input-group">
                          <input type="text" class="form-control" name="aranan" placeholder="Arama...">
                          <span class="input-group-btn">
                      <button class="btn btn-default" type="submit" name="arama">Ara</button>
                    </span>
                      </div>
                     </form>
                  </div>
              </div>
            <div class="clearfix"></div>

            <div class="row">
              <div class="col-md-12 col-sm-12 col-xs-12">
                  <div class="col-md-12 col-sm-12 col-xs-12">
                      <div class="x_panel">
                        
                          <div class="x_content table-responsive">

                              <table class="table">
                                  <thead>
                                  <tr>
                                      <th>#</th>
                                      <th>Menu Ust</th>
                                      <th>Menu  Ad</th>
                                      <th>Menu  Detay</th>
                                      <th>Menu  Url</th>
                                      <th>Menu  Sira</th>
                                      <th>Menu  Durum</th>
                                      <th></th>
                                      <th></th>
                                  </tr>
                                  </thead>
                                  <tbody>
                                  <?php

                                  foreach ($menusor as $menuCek)
                                  {
                                      $menu_id = $menuCek['menu_id']; ?>



                                

                                  <tr>
                                      <td scope="row"><?php echo $menuCek['menu_id']; ?></td>
                                      <td scope="row"><?php echo $menuCek['menu_ust']; ?></td>
                                      <td scope="row"><?php echo $menuCek['menu_ad']; ?></td>
                                      <td scope="row"><?php echo $menuCek['menu_detay']; ?></td>
                                      <td scope="row"><?php echo $menuCek['menu_url']; ?></td>
                                      <td scope="row"><?php echo $menuCek['menu_sira']; ?></td>
                                      <td scope="row"><?php
                                      if($menuCek['menu_durum']=='1')
                                      {
                                          echo "AKTİF";
                                      }
                                      else{
                                          echo "PASİF";
                                      }
                                      
                                      ?></td>



                                     <td>
                                      <a href="menu_duzenle.php?menu_id=<?php echo $menuCek['menu_id'];?>"><button  type="submit" class="btn btn-success">Güncelle</button></a>
                                      </td>

                                     <td><button class="btn btn-danger" data-toggle="modal" data-target="#ornekModal"><i class="glyphicon glyphicon-trash"></i> Sil</button></td>
                        
                                 
                                 </tr>
<div class="modal fade" tabindex="-1" role="dialog" id="ornekModal">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
        <h4 class="modal-title">Silmek İstediğinize Emin Misiniz?</h4>
      </div>
      <div class="modal-body">
        <p>Yapılan silme işlemi geri alınamaz!!</p>
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-default" data-dismiss="modal">Kapat</button>
     <a href="menu_sil.php?menu_id=<?php echo $menuCek['menu_id'];?>"><button class="btn btn-danger"><i class="glyphicon glyphicon-trash"></i> Sil</button></a>
      </div>
    </div><!-- /.modal-content -->
  </div><!-- /.modal-dialog -->
</div><!-- /.modal -->

                                      <?php
                                      $altmenuSor=$db->prepare("select * from menuler where menu_ust=:menu_id order by menu_sira asc");
                                      $altmenuSor->execute(array("menu_id"=>$menu_id));
                                     while($altmenucek=$altmenuSor->fetch(PDO::FETCH_ASSOC))
                                      {?>

                                      <tr>
                                          <td scope="row"><?php echo $altmenucek['menu_id']; ?></td>
                                          <td scope="row"><?php echo $altmenucek['menu_ust']; ?></td>
                                          <td scope="row"><b>******</b>&nbsp;&nbsp;<?php echo $altmenucek['menu_ad']; ?></td>
                                          <td scope="row"><?php echo substr($altmenucek['menu_detay'],0,100); ?></td>
                                          <td scope="row"><?php echo $menuCek['menu_url']; ?></td>
                                          <td scope="row"><?php echo $altmenucek['menu_sira']; ?></td>
                                          <td scope="row"><?php
                                              if($altmenucek['menu_durum']=='1')
                                              {
                                                  echo "AKTİF";
                                              }
                                              else{
                                                  echo "PASİF";
                                              }
                                              ?></td>

    
<div class="modal fade" tabindex="-1" role="dialog" id="altmenuornekModal">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
        <h4 class="modal-title">Silmek İstediğinize Emin Misiniz?</h4>
      </div>
      <div class="modal-body">
        <p>Yapılan silme işlemi geri alınamaz!!</p>
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-default" data-dismiss="modal">Kapat</button>
       <a href="menu_sil.php?menu_id=<?php echo $altmenucek['menu_id'];?>"><button class="btn btn-danger"><i class="glyphicon glyphicon-trash"></i> Sil</button></a>
      </div>
    </div><!-- /.modal-content -->
  </div><!-- /.modal-dialog -->
</div><!-- /.modal -->
                                          <td>
                                              <a href="menu_duzenle.php?menu_id=<?php echo $altmenucek['menu_id'];?>"><button  type="submit" class="btn btn-success">Güncelle</button></a>
                                          </td>
                                          <td><button class="btn btn-danger" data-toggle="modal" data-target="#altmenuornekModal"><i class="glyphicon glyphicon-trash"></i> Sil</button></td>
                                      </tr>




                                  <?php  }
                                  }
                                  ?>




                                  </tbody>
                              </table>



                          </div>
                      </div>
                  </div>
              </div>
            </div>
          </div>
        </div>
        <!-- /page content -->

          <?php
include "footer.php";
?>