title: Passing the data in the tables from database to modal
body: <p>I am trying to pass the data in the table to a modal textbox through a clickable row. The data's are already displayed in the table. When row is clicked, it displays the modal but the textboxes are blank. The data's in the table was from the database.</p>
  
  <p>This is the codes:</p>
  
  <p>Php:</p>
  
  <pre><code>  &lt;!DOCTYPE html&gt;
    &lt;html&gt;
  &lt;head&gt;
      &lt;title&gt;&lt;/title&gt;
  
      &lt;meta name = "viewport" content = "width= device-width, initial-scale=1"&gt;
      &lt;link rel = "stylesheet" href = "bs/css/bootstrap.css"&gt;
  
      &lt;script src = "bs/js/jquery.min.js"&gt;&lt;/script&gt;
      &lt;script src = "bs/js/bootstrap.min.js"&gt;&lt;/script&gt;
  
      &lt;meta charset="utf-8"&gt;
  
  &lt;/head&gt;  
  &lt;body&gt;        
      &lt;div class="container"&gt;
          &lt;div class="header"&gt;
              &lt;?php include("header.php"); ?&gt;
          &lt;/div&gt;
          &lt;div class = "navigation"&gt;
              &lt;?php include("navigator.php"); ?&gt;
          &lt;/div&gt;
      &lt;/div&gt;
  
      &lt;center&gt;          
      &lt;style&gt;
          table tr:not(:first-child){
              cursor: pointer;
          }
          table tr:not(:first-child)hover{
              background-color:azure;
              color:black;
  
          }
      &lt;/style&gt; 
  
      &lt;?php
          include("dbConfig.php");
  
          $result = mysqli_query ($con, "SELECT * FROM information");
          echo "&lt;table id=table border = 1 width = 50%&gt;
              &lt;tr&gt;
              &lt;th align = center&gt; Control # &lt;/th&gt;
              &lt;th&gt; Last Name &lt;/th&gt;
              &lt;th&gt; First Name &lt;/th&gt;
              &lt;th&gt; Contact Number &lt;/th&gt;
              &lt;/tr&gt;"; 
          while($row=mysqli_fetch_array($result)){
              echo "&lt;form action = method =post&gt;";
              echo "&lt;tr data-toggle=modal data-target=#fmodal name = pass type = submit&gt;";
              echo "&lt;td id='cn'&gt;".$row['Control_Number']. "&lt;/td&gt;";
              echo "&lt;td&gt;".$row['Last_Name']. "&lt;/td&gt;";
              echo "&lt;td&gt;".$row['First_Name']. "&lt;/td&gt;";
              echo "&lt;td&gt;".$row['Contact_Number']. "&lt;/td&gt;";
              echo "&lt;/tr&gt;";
              echo "&lt;/form&gt;";
          }
          echo "&lt;/table&gt;";
  
          if(isset($_POST['submit'])){
              $res = mysqli_query($con, "SELECT * FROM information WHERE Control_Number=$_POST[cn]");
              while($rowval = mysqli_fetch_array($res)){
                  $controlnumber= $rowval['Control_Number'];
                  $lastname= $rowval['Last_Name'];
                  $firstname= $rowval['First_Name'];
                  $contactnumber= $rowval['Contact_Number'];
              }
          }
      ?&gt;
  
      &lt;div class = "modal fade" id = "fmodal" role = "dialog"&gt;
          &lt;div class = "modal-dialog" role = "document"&gt;
              &lt;div class = "modal-content"&gt;
                  &lt;div class = "modal-header"&gt;
                      &lt;button type = "button" class = "close" data-dismiss = "modal"&gt;&amp;times;&lt;/button&gt;
                      &lt;h4&gt;FORM&lt;/h4&gt;
                  &lt;/div&gt;
                  &lt;div class = "modal-body text-center"&gt;
                      &lt;label&gt;Control Number:&lt;/label&gt;
                      &lt;input class = "input-lg" type = "text" id = "Control_Number" value = '&lt;?php echo $controlnumber; ?&gt;'&gt;&lt;br&gt;
                      &lt;label&gt;Last Name:&lt;/label&gt;
                      &lt;input class = "input-lg" type = "text" id = "Last_Name" value = '&lt;?php echo $lastname; ?&gt;'&gt;&lt;br&gt;
                      &lt;label&gt;First Name:&lt;/label&gt;
                      &lt;input class = "input-lg" type = "text" id = "First_Name" value = '&lt;?php echo $firstname; ?&gt;'&gt;&lt;br&gt;
                      &lt;label&gt;Contact Number:&lt;/label&gt;
                      &lt;input class = "input-lg" type = "text" id = "Contact_Number" value = '&lt;?php echo $contactnumber; ?&gt;'&gt;&lt;br&gt;
                  &lt;/div&gt;                    
              &lt;/div&gt;
          &lt;/div&gt;
      &lt;/div&gt;
      &lt;/center&gt;
  &lt;/body&gt;
  </code></pre>
  
  <p></p>