Good day! I've got a problem in my bootstrap modal where I want to delete a post using a modal.
Here is my PHP code where it toggles the delete_modal.php
<?php
if ($row['member_id'] == $_SESSION['member_id']){
echo "
<div style='float:right;'>
<a href='#<?php echo $id; ?>' data-toggle='modal' data-target='#myModal'>Delete</a>
</div>";}
else{
echo "
<div style='float:right;'>
<a href='#'>Delete</a>
</div>";
}
?>
Next this is my delete_modal.php
<div class="modal fade" id="myModal" role="dialog">
<div class="modal-dialog">
<!-- Modal content-->
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h4 class="modal-title">Modal Header</h4>
</div>
<div class="modal-body">
<p>Some text in the modal.</p>
</div>
<div class="modal-footer">
<button id="<?php echo $id; ?>" href="deleteposthome.php?id='.$row['post_id'].'" type="button" class="btn btn-danger" data-dismiss="modal">Delete</button>
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
Now this is my deleteposthome.php
<?php
require ("connection.php");
?>
<?php
$id =$_GET['id'];
mysql_query("DELETE FROM posts WHERE post_id = '$id'")
or die(mysql_error());
?>
I don't know how to get ID so that it can be deleted using modal ! please help me
This is my answer, for how many months I've asked this question.
<div class='modal-footer' style='background-color:#1F4E78;'>
<a class='btn btn-danger' href='deleteposthome.php?id=".$row['post_id']."'> Delete</a>
</div>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.