title: Bootstrap modal didn't display fix
body: <p>I'm working on a PHP admin management page with CRUD. In this page we want to add a vehicle and to edit data which is present in a SQL record table by using a modal box which contains a form to insert and update data. But I have a problem:</p>
  
  <ol>
  <li><p>The modal box didn't display. But I've tried to substitute it with a pure HTML and CSS modal box that works.</p></li>
  <li><p>The pure modal box works perfectly, but in the edit column of the table only the first row can display an edit modal all, the other row didn't show a modal.</p></li>
  </ol>
  
  <p>Complete page code:</p>
  
  <pre class="lang-php prettyprint-override"><code>&lt;?php 
  require_once '../inc/function.php';
  adac();
  require_once '../inc/db.php';
  if(!empty($_POST)){
  $requ = $pdo-&gt;prepare('INSERT INTO `vehicules`(`marques`, `modele`, `annee`, `proprio`, `imma`) VALUES (?, ?, ?, ?, ?)');
  $rl= $requ-&gt;execute([$_POST['mq'], $_POST['ml'], $_POST['an'], $_POST['pro'], $_POST['im']]);
  if($rl){
      $_SESSION['flash']['success'] = "Informations enregistrées!";
  }else{
      $_SESSION['flash']['danger'] = "Echec!"; 
  }
  }
  ?&gt;
  &lt;!DOCTYPE HTML&gt;
  
  &lt;html&gt;
  
  &lt;head&gt;
  &lt;script src="../bootstrap-4.3.1-dist/js/bootstrap.min.js"&gt;&lt;/script&gt;
  &lt;script src="../js/jquery.min.js"&gt;&lt;/script&gt;
  &lt;script src="../js/popper.min.js"&gt;&lt;/script&gt;
  
      &lt;meta http-equiv="Content-Type" content="text/html;charset=UTF-8"&gt;
    &lt;title&gt;LeLoux&lt;/title&gt;
    &lt;link rel="stylesheet" href="../bootstrap-4.3.1-dist\css\bootstrap.min.css"&gt;
  &lt;style&gt;
  body {
    position: relative;
    margin: 0;
    padding-bottom: 6rem;
    min-height: 100%;
  }
  
  html {
    height: 100%;
    box-sizing: border-box;
  }
  
  *,
  *:before,
  *:after {
    box-sizing: inherit;
  }
  .o{
      margin: 10px;   }
  .footer {
    position: absolute;
    right: 0;
    bottom: 0;
    left: 0;
    padding: 1rem;
    background-color: light;
    text-align: center;
  }
  .lk{
      width: 135px;
      height: 40px;
      border: 1.6px solid grey;
      border-radius: 5px;
      margin: 10px;
      display: inline-block;
  }
  .po{
      width: 34px;
      height: 34px;
      background: transparent;
      float: left;
      margin: 1px;
      cursor: pointer;
  }
  .poa{
      text-align: center;
      margin: 5px;
      text-decoration: none;
  }
  .nav-item{
      width: 17%;
      text-align: center;
      margin:5px;
  
  }
  .bob{
            width: 720px;
  }
  .mo{
      margin: 5px;
      border: 1px solid transparent;
    width: 1100px;
    height: auto;
  }
  .fo{
      display: inline-block;
      }
  a {
      text-decoration: none;
      color: black;
  }
  a:hover{
      color: grey;
  }
  .co{
  max-height:860px;
  height:460px;/*pour IE qui comprend rien, et qui ne reconnait pas min-height, mais qui comprend mal height*/
  max-width:1100px;
  width:980px;/*pour IE qui comprend rien*/
  overflow:auto;/*pour activer les scrollbarres*/
  }
  
  
  /* The Modal (background) */
  .modal {
    display: none; /* Hidden by default */
    position: fixed; /* Stay in place */
    z-index: 1; /* Sit on top */
    padding-top: 100px; /* Location of the box */
    left: 0;
    top: 0;
    width: 100%; /* Full width */
    height: 100%; /* Full height */
    overflow: auto; /* Enable scroll if needed */
    background-color: rgb(0,0,0); /* Fallback color */
    background-color: rgba(0,0,0,0.4); /* Black w/ opacity */
  }
  
  /* Modal Content */
  .modal-content {
    background-color: #fefefe;
    margin: auto;
    padding: 20px;
    border: 1px solid #888;
    width: 90%;
  
  }
  
  /* The Close Button */
  .close {
    color: #fefefe;
    float: right;
    font-size: 28px;
    font-weight: bold;
  }
  
  .close:hover,
  .close:focus {
    color: #fff;
    text-decoration: none;
    cursor: pointer;
  }
  .modal-header{
    background-color: #5e5e90;
    color: #fff;
    margin-top: -20%;
    width: 110%;
    height: 15%;
    padding: 16px;
    margin-left: -19px;
  }
  .btnq{
    background-color: #5e5e90;
    color: #fff;
  }
  .btnp{
    background-color:#fff;
    color:#5e5e90;
    border: 2px solid #5e5e90;
    font-weight: bolder;
  }
  .nu{
      text-transform: uppercase;
  }
  &lt;/style&gt;
  &lt;/head&gt;
  &lt;body class="bg-light"&gt;
  &lt;!--################## add modal  ###############################--&gt;
  &lt;!-- Modal --&gt;
  &lt;div class="modal fade" id="eModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true"&gt;
    &lt;div class="modal-dialog" role="document"&gt;
      &lt;div class="modal-content"&gt;
        &lt;div class="modal-header"&gt;
          &lt;h5 class="modal-title" id="exampleModalLabel"&gt;Ajouter un vehicule&lt;/h5&gt;
          &lt;button type="button" class="close" data-dismiss="modal" aria-label="Close"&gt;
            &lt;span aria-hidden="true"&gt;&amp;times;&lt;/span&gt;
          &lt;/button&gt;
        &lt;/div&gt;
        &lt;div class="modal-body"&gt;
        &lt;form action="" method="POST"&gt;
                  &lt;table cellspacing="3"cellpadding ="6"&gt;
                    &lt;tr&gt;
                      &lt;td&gt;&lt;b&gt;Marque&lt;/b&gt;&lt;br&gt;
                      &lt;input type="text" class="form-control nu" value="" name="mq" id="mq"&gt;
                  &lt;/td&gt;
  
                      &lt;td&gt;&lt;b&gt;Modèle&lt;/b&gt;&lt;br&gt;
                      &lt;input type="text" class="form-control" name="ml" id="ml"&gt;
                        &lt;/td&gt;
                    &lt;/tr&gt;
  
                    &lt;tr&gt;
                        &lt;td&gt;&lt;b&gt;Année&lt;/b&gt;&lt;br&gt;
                        &lt;input type="text" class="form-control" name="an" id="an"&gt;
                        &lt;/td&gt;
  
                        &lt;td&gt;&lt;b&gt;Transmission&lt;/b&gt;&lt;br&gt;
                        &lt;input type="text" class="form-control" id=""&gt;
                          &lt;/td&gt;
                      &lt;/tr&gt;
  
                      &lt;tr&gt;
                          &lt;td&gt;
                            &lt;b&gt;N de chassis&lt;/b&gt;&lt;br&gt;
                            &lt;input type="text" class="form-control" id=""&gt;
                          &lt;/td&gt;
                          &lt;td&gt;
                              &lt;b&gt;Immatriculation&lt;/b&gt;&lt;br&gt;
                              &lt;input type="text" class="form-control" name="im" id="im"&gt;
                            &lt;/td&gt;
                      &lt;/tr&gt;
                      &lt;tr&gt;
                          &lt;td&gt;&lt;b&gt;Carburant&lt;/b&gt;&lt;br&gt;
                          &lt;input type="text" class="form-control" id=""&gt;
                          &lt;/td&gt;
  
                          &lt;td&gt;&lt;b&gt;Couleur&lt;/b&gt;&lt;br&gt;
                          &lt;input type="text" class="form-control" id=""&gt;
                            &lt;/td&gt;
                        &lt;/tr&gt;
  
                        &lt;tr&gt;
                            &lt;td&gt;
                              &lt;b&gt;Propriétaire&lt;/b&gt;&lt;br&gt;
                              &lt;input type="text" class="form-control" name="pro" id="pro" &gt;
                            &lt;/td&gt;
                            &lt;td&gt;
                                &lt;b&gt;Contact&lt;/b&gt;&lt;br&gt;
                                &lt;input type="text" class="form-control" id=""&gt;
                              &lt;/td&gt;
                        &lt;/tr&gt;
                  &lt;/table&gt;
  
              &lt;/div&gt;
              &lt;div class="modal-footer"&gt;
                  &lt;button type="reset" class="btn btnp" data-dismiss="modal"&gt;Annuler&lt;/button&gt;
                  &lt;button type="submit" class="btn btnq"&gt;Enregistrer&lt;/button&gt;
  
              &lt;/div&gt;
              &lt;/form&gt;
        &lt;/div&gt;
        &lt;div class="modal-footer"&gt;
          &lt;button type="button" class="btn btn-secondary" data-dismiss="modal"&gt;Close&lt;/button&gt;
          &lt;button type="button" class="btn btn-primary"&gt;Save changes&lt;/button&gt;
        &lt;/div&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/div&gt;
  
  &lt;!--################## edit modal  ###############################--&gt;
  &lt;!-- Modal --&gt;
  &lt;div class="modal fade" id="exampleModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true"&gt;
    &lt;div class="modal-dialog" role="document"&gt;
      &lt;div class="modal-content"&gt;
        &lt;div class="modal-header"&gt;
          &lt;h5 class="modal-title" id="exampleModalLabel"&gt;Modifier un vehicule&lt;/h5&gt;
          &lt;button type="button" class="close" data-dismiss="modal" aria-label="Close"&gt;
            &lt;span aria-hidden="true"&gt;&amp;times;&lt;/span&gt;
          &lt;/button&gt;
        &lt;/div&gt;
        &lt;div class="modal-body"&gt;
        &lt;form action="" method="POST"&gt;
                  &lt;table cellspacing="3"cellpadding ="6"&gt;
                    &lt;tr&gt;
                      &lt;td&gt;&lt;b&gt;Marque&lt;/b&gt;&lt;br&gt;
                      &lt;input type="text" class="form-control nu" value="" name="mq" id="mq"&gt;
                  &lt;/td&gt;
  
                      &lt;td&gt;&lt;b&gt;Modèle&lt;/b&gt;&lt;br&gt;
                      &lt;input type="text" class="form-control" name="ml" id="ml"&gt;
                        &lt;/td&gt;
                    &lt;/tr&gt;
  
                    &lt;tr&gt;
                        &lt;td&gt;&lt;b&gt;Année&lt;/b&gt;&lt;br&gt;
                        &lt;input type="text" class="form-control" name="an" id="an"&gt;
                        &lt;/td&gt;
  
                        &lt;td&gt;&lt;b&gt;Transmission&lt;/b&gt;&lt;br&gt;
                        &lt;input type="text" class="form-control" id=""&gt;
                          &lt;/td&gt;
                      &lt;/tr&gt;
  
                      &lt;tr&gt;
                          &lt;td&gt;
                            &lt;b&gt;N de chassis&lt;/b&gt;&lt;br&gt;
                            &lt;input type="text" class="form-control" id=""&gt;
                          &lt;/td&gt;
                          &lt;td&gt;
                              &lt;b&gt;Immatriculation&lt;/b&gt;&lt;br&gt;
                              &lt;input type="text" class="form-control" name="im" id="im"&gt;
                            &lt;/td&gt;
                      &lt;/tr&gt;
                      &lt;tr&gt;
                          &lt;td&gt;&lt;b&gt;Carburant&lt;/b&gt;&lt;br&gt;
                          &lt;input type="text" class="form-control" id=""&gt;
                          &lt;/td&gt;
  
                          &lt;td&gt;&lt;b&gt;Couleur&lt;/b&gt;&lt;br&gt;
                          &lt;input type="text" class="form-control" id=""&gt;
                            &lt;/td&gt;
                        &lt;/tr&gt;
  
                        &lt;tr&gt;
                            &lt;td&gt;
                              &lt;b&gt;Propriétaire&lt;/b&gt;&lt;br&gt;
                              &lt;input type="text" class="form-control" name="pro" id="pro" &gt;
                            &lt;/td&gt;
                            &lt;td&gt;
                                &lt;b&gt;Contact&lt;/b&gt;&lt;br&gt;
                                &lt;input type="text" class="form-control" id=""&gt;
                              &lt;/td&gt;
                        &lt;/tr&gt;
                  &lt;/table&gt;
  
              &lt;/div&gt;
              &lt;div class="modal-footer"&gt;
                  &lt;button type="reset" class="btn btnp" data-dismiss="modal"&gt;Annuler&lt;/button&gt;
                  &lt;button type="submit" class="btn btnq"&gt;Enregistrer&lt;/button&gt;
  
              &lt;/div&gt;
              &lt;/form&gt;
        &lt;/div&gt;
        &lt;div class="modal-footer"&gt;
          &lt;button type="button" class="btn btn-secondary" data-dismiss="modal"&gt;Close&lt;/button&gt;
          &lt;button type="button" class="btn btn-primary"&gt;Save changes&lt;/button&gt;
        &lt;/div&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/div&gt;
  
  
  
  
  
  
  
  
  
   &lt;div class="o"&gt;&lt;h3 class="font-weight-bolder"&gt;LeLoux&lt;/h3&gt;  &lt;/div&gt;
    &lt;div class="container bob"&gt;
        &lt;ul class="nav nav-tabs" role="tablist"&gt;
      &lt;li class="nav-item shadow-sm"&gt;
        &lt;a class="nav-link active" data-toggle="tab" href="advehi.php"&gt;Vehicules&lt;/a&gt;
      &lt;/li&gt;
      &lt;li class="nav-item shadow-sm"&gt;
        &lt;a class="nav-link" data-toggle="tab" href="adrepa.php"&gt;Reparateurs&lt;/a&gt;
      &lt;/li&gt;
      &lt;li class="nav-item shadow-sm"&gt;
        &lt;a class="nav-link" data-toggle="tab" href="adinter.php"&gt;Interventions&lt;/a&gt;
      &lt;/li&gt;
       &lt;li class="nav-item shadow-sm"&gt;
        &lt;a class="nav-link" data-toggle="tab" href="adfor.php"&gt;Forfaits&lt;/a&gt;
      &lt;/li&gt;
       &lt;li class="nav-item shadow-sm"&gt;
        &lt;a class="nav-link" data-toggle="tab" href="adfac.php"&gt;Facturations&lt;/a&gt;
      &lt;/li&gt;
    &lt;/ul&gt;
    &lt;/div&gt;
  
  
  
  
  
  
  
   &lt;center&gt;&lt;div class="tab-content mo"&gt;
   &lt;div  class="container shadow tab-pane fade show active "&gt;&lt;br&gt;
    &lt;div class="co"&gt; 
  
        &lt;table class="table"&gt;
            &lt;thead&gt;
              &lt;tr&gt;
                &lt;th scope="col"&gt;Marques&lt;/th&gt;
                &lt;th scope="col"&gt;Modèle&lt;/th&gt;
                &lt;th scope="col"&gt;Année&lt;/th&gt;
                &lt;th scope="col"&gt;&lt;div class="dropdown"&gt;
            &lt;button class="btn  dropdown-toggle" type="button" id="dropdownMenuButton" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"&gt;
                    &lt;b&gt; Propriétaire&lt;/b&gt;
            &lt;/button&gt;
            &lt;/th&gt;
                &lt;th scope="col"&gt;Immatriculation&lt;/th&gt;
                &lt;th scope="col"&gt;&lt;div class="dropdown"&gt;
            &lt;button class="btn  dropdown-toggle" type="button" id="dropdownMenuButton" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"&gt;
                    &lt;img src="../im/settings.png" class="po"&gt;
            &lt;/button&gt;
          &lt;/th&gt;
              &lt;/tr&gt;
            &lt;/thead&gt;
            &lt;tbody&gt;
  
  
  
  
  
  
  
  
  
  
  
  
            &lt;?php 
  
  $req = $pdo-&gt;prepare('SELECT DISTINCT * FROM vehicules');
   $req-&gt;execute();
  $user = $req-&gt;fetchAll();
  foreach ($user as $row) { ?&gt;
  &lt;?= "&lt;tr&gt;&lt;th scope='row'&gt;".$row['marques']."&lt;/th&gt;&lt;td&gt;".$row['modele']."&lt;/td&gt;&lt;td&gt;".$row['annee']."&lt;/td&gt;&lt;td&gt;".$row['proprio']."&lt;/td&gt;&lt;td&gt;".$row['imma']."&lt;/td&gt;&lt;td&gt;&lt;img src='../im/pencil.png' class='po' id='nie' data-toggle='modal' data-target='#exampleModal'&gt;&lt;/td&gt;&lt;/tr&gt;"; ?&gt;         
  &lt;?php } ?&gt;
  &lt;/tbody&gt;
  &lt;/table&gt;
  &lt;/div&gt;
  &lt;/div&gt;&lt;/center&gt;
  
  
  
  
  
  
  
     &lt;div class="footer"&gt;
        &lt;!-- Button trigger modal --&gt;
  &lt;button type="button" class="lk float-left" data-toggle="modal" data-target="#eModal"&gt;
  &lt;img src="../im/add.png" class="po"&gt; &lt;p class="poa"&gt;Ajouter&lt;/p&gt;
  &lt;/button&gt;
    &lt;a href=#&gt;&lt;div class="lk float-left"&gt;&lt;img src="../im/search.png"  class="po"&gt; &lt;p class="poa"&gt;Rechercher&lt;/p&gt;&lt;/div&gt;&lt;/a&gt;
    &lt;a href="#"&gt;&lt;div class="lk float-left"&gt;&lt;img src="../im/opera.png" class="po"&gt; &lt;p class="poa"&gt;Details&lt;/p&gt;&lt;/div&gt;&lt;/a&gt;
    &lt;a href="index.php"&gt;&lt;div class="lk float-right"&gt;&lt;img src="../im/close.png" class="po"&gt; &lt;p class="poa"&gt;Fermer&lt;/p&gt;&lt;/div&gt;&lt;/a&gt;
  &lt;/div&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>pure html css and js modal:</p>
  
  <p>html:</p>
  
  <pre><code>&lt;!-- Trigger/Open The Modal --&gt;
  &lt;button id="myBtn"&gt;Open Modal&lt;/button&gt;
  
  &lt;!-- The Modal --&gt;
  &lt;div id="myModal" class="modal"&gt;
  
    &lt;!-- Modal content --&gt;
    &lt;div class="modal-content"&gt;
      &lt;span class="close"&gt;&amp;times;&lt;/span&gt;
      &lt;p&gt;Some text in the Modal..&lt;/p&gt;
    &lt;/div&gt;
  
  &lt;/div&gt;
  </code></pre>
  
  <p>css:</p>
  
  <pre><code>/* The Modal (background) */
  .modal {
    display: none; /* Hidden by default */
    position: fixed; /* Stay in place */
    z-index: 1; /* Sit on top */
    left: 0;
    top: 0;
    width: 100%; /* Full width */
    height: 100%; /* Full height */
    overflow: auto; /* Enable scroll if needed */
    background-color: rgb(0,0,0); /* Fallback color */
    background-color: rgba(0,0,0,0.4); /* Black w/ opacity */
  }
  
  /* Modal Content/Box */
  .modal-content {
    background-color: #fefefe;
    margin: 15% auto; /* 15% from the top and centered */
    padding: 20px;
    border: 1px solid #888;
    width: 80%; /* Could be more or less, depending on screen size */
  }
  
  /* The Close Button */
  .close {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
  }
  
  .close:hover,
  .close:focus {
    color: black;
    text-decoration: none;
    cursor: pointer;
  }
  </code></pre>
  
  <p>js:</p>
  
  <pre><code>// Get the modal
  var modal = document.getElementById("myModal");
  
  // Get the button that opens the modal
  var btn = document.getElementById("myBtn");
  
  // Get the &lt;span&gt; element that closes the modal
  var span = document.getElementsByClassName("close")[0];
  
  // When the user clicks on the button, open the modal
  btn.onclick = function() {
    modal.style.display = "block";
  }
  
  // When the user clicks on &lt;span&gt; (x), close the modal
  span.onclick = function() {
    modal.style.display = "none";
  }
  
  // When the user clicks anywhere outside of the modal, close it
  window.onclick = function(event) {
    if (event.target == modal) {
      modal.style.display = "none";
    }
  }
  </code></pre>