I am trying to echo a bootstrap modal with php . I have some data from table database and if I click on button and try to echo modal on If(isset) condition, the modal is not showing. see my Code Here:
<?php
//insert in persnaol user table
$sql = "SELECT id,date,status FROM $x order by id DESC;";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
while($row = $result->fetch_assoc()) {
echo "<div class='border'> ";
echo "";
echo "<form action='#' method='POST'>";
$id = $row['id'];
echo "<input type='show' name='statusid' value='$id' >";
echo "<p> " . $row["status"] ."</p><br>";
echo "<a class='pull-right' ><input type='submit' value='Edit Post' class='btn1' name='editbtn' data-toggle='modal' data-target='#qModal' ></a>";
echo "<small> " . $row["date"]. "</small><br>";
$editid= $row['id'];
echo "</form><br>";
echo "</div>";
echo "<br>";
echo'
<script>
$("form").submit(function(e){
e.preventDefault();
});
</script>';
}
} else {
echo "hello";
}
?>
and my modal html code is here. modal window is not established.
<?php
require'db.php';
if(isset($_POST['editbtn'])){
$x = $_SESSION['username'];
$id=$_POST["statusid"];
echo '<div class="modal fade" id="qModal" role="dialog" >';
echo ' <div class="modal-dialog" style="z-index:1000;">';
echo '<div class="modal-content">';
echo '<div class="modal-header">';
echo ' <button type="button" class="close" data-dismiss="modal">×</button>';
echo ' <h4 class="modal-title">Post Editing.</h4>';
echo ' </div>';
echo ' <div class="modal-body">';
echo ' <P>';
echo $id;
echo '</p>';
echo ' <form>';
echo ' <textarea value="" >hello</textarea>';
echo ' </form>';
echo '</div>';
echo ' <div class="modal-footer">';
echo ' <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>';
echo ' </div> </div> </div> </div>';
}
?>