v2.5.2
Giriş yap

Bootstrap Modal Kullanım Hatası

ynscnr55
995 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?

Cevap yaz
Cevaplar (7)
emmir2
969 gün önce
<?php
include 'db-ayar.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();
}
?>

<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
        <!-- 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="#modalmenu<?=$menuCek['menu_id']?>"><i class="glyphicon glyphicon-trash"></i> Sil</button></td>
                                <div class="modal fade" tabindex="-1" role="dialog" id="modalmenu<?=$menuCek['menu_id']?>">
                                  <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 -->

                                 
                                 </tr>
                                
                                      <?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>
                                          <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="#altmenu<?=$menuCek['menu_id']?>"><i class="glyphicon glyphicon-trash"></i> Sil</button></td>
                                           <div class="modal fade" tabindex="-1" role="dialog" id="altmenu<?=$menuCek['menu_id']?>">
                                            <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 -->

                                      </tr>




                                  <?php  }
                                  }
                                  ?>




                                  </tbody>
                              </table>



                          </div>
                      </div>
                  </div>
              </div>
            </div>
          </div>
        </div>
        <!-- /page content -->
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>
          <?php
include "footer.php";
?>
ynscnr55
969 gün önce

yazdıgınız kodlardan scriptleri ve link reel kodunu silince çalıştı teşekkür ederim :)

ynscnr55
969 gün önce

Maalesef olmadı hocam. hem görüntü bozuldu hem de kod çalışmadı sürekli loading butonu dönüyor.

ynscnr55
969 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";
?>
emmir2
970 gün önce

php kodlarını iletirmisin

ynscnr55
970 gün önce

Yaptım ama maalesef işe yaramadı.

emmir2
970 gün önce

modalı döngü içine almalısın

 <?php 
$query = $db->prepare("SELECT * FROM menuler");
$query->execute();
  $menu=$query->fetchAll();
   if($query->rowCount()){
     foreach($menu as $row){ ?>
      
      <div class="modal fade" tabindex="-1" role="dialog" id="<?php echo $row['menu_id']; ?>">
  <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 $row['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 }} ?>