I cannot foreach loop my comment & reply system. I read many article and example but can't apply these in my case.
This is my comment system with reply, here every think is working well. But reply form work for only last/new comment. So i need to loop each comment. But can't do, please help me.
global $dbh;
$results = mysqli_query($dbh,"SELECT * FROM comments_lite WHERE qazi_id='$tutid' ORDER BY id DESC LIMIT 5") or die(mysqli_error($dbh));
echo'<div class="comments"><div id="updates"><div class="content"><comment>';
// Show only main comment
while($row = mysqli_fetch_array($results))
{ $id = $row['id'];
$qazi_id = $row['qazi_id'];
$username = $row['username'];
$description = $row['description'];
$parent_id = $row['parent_id'];
$date = $row['date'];
//echo comment
echo'<div class="comment">
<div class="cdomment_cheder">';
echo'<p>'.$username.' Says:</p>';
echo'<span>'.$date.'</span><br/>
<div class="avatarcnt">
<img alt="" src="uploadprofile/'.$u_imgurl.'"/>
</div></div></div>
<div class="cdomment_text">';
if ($description=="") {echo '';}
else echo''.htmlentities($description).'<br>';
echo '</div>';
//reply
echo'<div class="reply_box">Reply</div>';
//Reply form
echo'<div id="loader"></div><div class="reply_here" id="reply_here-'.$id.'" style="display:none;">
<form action="" method="post" id="repfrm" enctype="multipart/form-data">
<fieldset id="cmntfs">
<input type="hidden" name="username" tabindex="1" id="author" value="'.$username.'"/>
<textarea name="replycom" rows="2" tabindex="4" id="replycom" value=""></textarea>
<input type="hidden" name="parent_id" id="parent_id" value="0" />
<input type="hidden" name="tutid2" id="tutid" value="'.$tutid2.'" />
<button type="submit" name="submit" value="" tabindex="5" id="submit" class="repfrm">Post Reply</button>
</fieldset>
</form>
</div>';
// Show Reply of each comment
$query = "SELECT * FROM comments_reply WHERE parent_id ='".$id."'";
$res = mysqli_query($dbh,$query);
while($row = mysqli_fetch_array($res))
{ $id = $row['id'];
$qazi_id = $row['qazi_id'];
$username = $row['username'];
$description = $row['description'];
$parent_id = $row['parent_id'];
$date = $row['date'];
//echo reply
echo' <div class="rcontent"><replycomment><ul>
<div class="comment">
<div class="cdomment_cheder">';
echo'<p class="name">'.$username.' Says:</p>';
echo'<span>'.$date.'</span><br/>
<div class="avatarcnt">
<img alt="" src="uploadprofile/'.$u_imgurl.'"/>
</div></div></div>
<div class="cdomment_text">';
if ($description=="") {echo '';}
else echo''.htmlentities($description).'<br>';
echo '</div>';
echo'</ul><replycomment></div>';
} //reply while close
} //comment while close
echo'</div><comment></div>';
Related
This question already has answers here:
"Notice: Undefined variable", "Notice: Undefined index", "Warning: Undefined array key", and "Notice: Undefined offset" using PHP
(29 answers)
Reference - What does this error mean in PHP?
(38 answers)
Closed 5 years ago.
I don't what is the wrong about this, there's no error but its not working about the update query. I don't know if its the latest code or old code. The first code is the accommodation_server.php.
Here's the structure:
<?php
session_start();
$title_room = "";
$room_size = "";
$occupancy = "";
$bed = "";
$rate = "";
$others = "";
$others1 = "";
$others2 = "";
$others3 = "";
$others4 = "";
$id = 0;
$edit_state = false;
//connect to the database
$db = mysqli_connect('localhost', 'root', '', 'accommodation');
//update
if (isset($_POST['update'])) {
$title_room = $_POST['text_title'];
$room_size = $_POST['text_size'];
$occupancy = $_POST['text_occupancy'];
$rate = $_POST['text_rate'];
$others = $_POST['text_others1'];
$others1 = $_POST['text_others2'];
$others2 = $_POST['text_others3'];
$others3 = $_POST['text_others4'];
$others4 = $_POST['text_others5'];
$bed = $_POST['text_bed'];
$description = $_POST['text_description'];
$id = $_POST['text_id'];
mysqli_query($db, "UPDATE rooms SET title_room = '$title_room', room_size = '$room_size', occupancy = '$occupancy', rate = '$rate', bed = '$bed', others = '$others', others1 = 'others1', others2 = '$others2', others3 = '$others3', others4 = '$others4', description = '$description' where id=$id");
$_SESSION['msg'] = "Room Updated!";
header('location: accommodation.php');
}
//retrieve records
$results = mysqli_query($db, "SELECT * FROM rooms");
?>
and this is the accommodation.php
<?php include ('accomodation_server.php');
//fetch the record
if (isset($_GET['edit'])) {
$id = $_GET['edit'];
$edit_state = true;
$rec = mysqli_query($db, "SELECT * FROM rooms where id=$id");
$record = mysqli_fetch_array($rec);
$title_room = $record['title_room'];
$room_size = $record['room_size'];
$occupancy = $record['occupancy'];
$rate = $record['rate'];
$others = $record['others'];
$others1 =$record['others1'];
$others2 = $record['others2'];
$others3 = $record['others3'];
$others4 = $record['others4'];
$bed = $record['Bed'];
$description = $record['description'];
$id = $record['id'];
}
?>
<html>
<head>
<title>C M S</title>
<link rel="stylesheet" type="text/css" href="css/accommodation.css">
<meta name="viewport" content="width=device-width, initial-scale: 1.0, user-scalable=0"/>
</head>
<body>
<?php if(isset($_SESSION['msg'])): ?>
<div class="msg">
<?php
echo $_SESSION['msg'];
unset($_SESSION['msg']);
?>
</div>
<?php endif ?>
<div id="container">
<div class="sidebar">
<ul id="nav">
<li>Dashboard</li>
<li><a class="selected" href="cms.php">CMS</a></li>
<li>Account Settings</li>
<li>Logout</li>
</ul>
</div>
<div class="content">
<br>
<br>
<h1>Accommodation</h1>
<p>Edit and remove images or description.</p>
<?php while ($row = mysqli_fetch_array($results)) { ?>
<form method="post" action="#">
<input type="hidden" name="id" value="<?php echo $id; ?>">
<div id="box">
<div class="title-room"><b> <!--title ng room--> <?php echo $row['title_room']; ?></b></a>
Edit
<input type="text" name="text_title" placeholder = "Enter the name of the room..." class="title" value="<?php echo $title_room; ?>">
</div>
<div class="box-top">Room Size:<p><?php echo $row['room_size']; ?></p></a>
<input type="text" name="text_size" placeholder = "Enter the size of the room..." class="size" value="<?php echo $room_size; ?>">
</div>
<div class="box-top">Bed: <p><?php echo $row['Bed']; ?></p></a>
<input type="text" name="text_bed" placeholder = "Enter the bedtype of the room..." class="bed" value="<?php echo $bed; ?>">
</div>
<div class="box-top">Occupancy: <p><?php echo $row['occupancy']; ?></p></a>
<input type="text" name="text_occupancy" placeholder = "Enter the occupancy of the room..." class="occupancy" value="<?php echo $occupancy; ?>">
</div>
<div class="box-top">Rate from: <p><?php echo $row['rate']; ?></p></a>
<input type="text" name="text_rate" placeholder = "Enter the rate of the room..." class="rate" value="<?php echo $rate; ?>">
</div>
<div class="box-top">Others:
<p class="others1"> <br>
<input type="text" name="text_others1" placeholder = "Others..." class="t_others1" value="<?php echo $others; ?>">
<?php echo $row['others']; ?></p> <br>
<p class="others2">
<input type="text" name="text_others2" placeholder = "Others..." class="t_others2" value="<?php echo $others1; ?>">
<?php echo $row['others1']; ?></p> <br>
<p class="others3">
<input type="text" name="text_others3" placeholder = "Others..." class="t_others3" value="<?php echo $others2; ?>">
<?php echo $row['others2']; ?></p><br>
<p class="others4">
<input type="text" name="text_others4" placeholder = "Others..." class="t_others4" value="<?php echo $others3; ?>">
<?php echo $row['others3']; ?></p> <br>
<p class="others5">
<input type="text" name="text_others5" placeholder = "Others..." class="t_others5" value="<?php echo $others4; ?>">
<?php echo $row['others4']; ?></p></a><br> </div>
<div class="box-panel">
<?php echo $row['description']; ?>
<br><p> </p>
<textarea placeholder = "Enter the Description of the Room..." rows="4" cols="100" class="description" name="text_description" value="<?php echo $description; ?>">
</textarea>
</div>
<?php if ($edit_state == false): ?>
<button type="submit" name="edit_button" class="edit_button">Edit</button>
<?php else: ?>
<button type="submit" name="update" class="btn">Update</button>
<?php endif ?>
</form>
<?php } ?>
<div id="box">
<div class="box-top">Destination</div>
<div class="box-panel">
Information of the resort (contact number, destination, etc)
</div>
<div id="box">
<div class="box-top">Accommodation</div>
<div class="box-panel">
Rooms, and the description of the room.
</div>
<div id="box">
<div class="box-top">Photos</div>
<div class="box-panel">
All images of the website.
</div>
</div>
</div>
</div>
<div id="header">
<div class="logo">Pacific Sky Beach Resort Admin Panel <span></span></div>
</div>
</body>
</html>
mysqli_query($db, "UPDATE rooms SET title_room = '$title_room', room_size = '$room_size', occupancy = '$occupancy', rate = '$rate', bed = '$bed', others = '$others', others1 = 'others1', others2 = '$others2', others3 = '$others3', others4 = '$others4', description = '$description' where id='$id'");
you missed the '' surrounding id='$id' in the first code sample
and again in the second
$rec = mysqli_query($db, "SELECT * FROM rooms where id='$id'");
also if you add print_r($db) after your query's it will show you if there are any errors in your sql request
code:
<?php
$id = $_GET['id'];
$sql = "select * from admin_menu where id = '$id'";
$result = mysqli_query($link,$sql);
while ($row = mysqli_fetch_array($result))
{
$menu_name = $row['menu_name'];
$menu_link = $row['menu_link'];
$priority = $row['priority'];
$admin_id = explode(",", $row['admin_id']);
}
if(isset($_POST['update']))
{
$admin_id = $_POST['admin_id'];
$chk="";
foreach($admin_id as $chk1)
{
$chk .= $chk1.",";
}
$menu_name = $_POST['menu_name'];
$menu_link = $_POST['menu_link'];
$priority = $_POST['priority'];
$sql = "update admin_menu set menu_name = '$menu_name', menu_link = '$menu_link', priority = '$priority', admin_id = '$chk' where id = '$id'";
$result = mysqli_query($link,$sql);
if($result == true)
{
$msg .= "<h3 style='color:green;'>update</h3>";
}
else
{
$msg .= "<h3 style='color:red;'>Error!</h3>";
}
}
?>
<form name="myform" method="post" >
<div class="row">
<label for="Producer_firstname">Admin Name</label>
<?php
foreach ($admin_id as $admin_id)
{
$chk = "";
if (in_array($chk, $admin_id))
{
$chk = 'checked="checked" ';
}
echo '<input type="checkbox" name="admin_id[]" value="'.$admin_id.'" '.$chk.'/><br/>';
}
?>
</div>
<div class="row">
<label for="Producer_firstname">Menu Name </label>
<input size="60" maxlength="255" name="menu_name" id="menu_name" value="<?php echo $menu_name; ?>" type="text" />
</div>
<div class="row">
<label for="Producer_lastname" >Menu Link </label>
<input size="60" maxlength="255" name="menu_link" id="menu_link" type="text" value="<?php echo $menu_link; ?>" />
</div>
<div class="row">
<label for="Producer_lastname" >Priority</label>
<select name="priority" id="priority">
<option value="<?php echo $priority; ?>"><?php echo $priority; ?></option>
<option value="">choose any one</option>
<option value="1">1</option>
<option value="0">0</option>
</select>
</div>
<div class="row buttons">
<button type="submit" name='update' id='update'>update Menu</button>
</div>
</form>
In this code I am fetching multiple checkbox value from table admin2 and I want when I update form value checkbox check if the value of checkbox is exist into database. How can I fix it ?
Thank You
Your code has few issues,
1. Update should be done before select query
2. List of admin not managed separately
3. Priority radio buttons not managed properly
Additional Suggestions,
1. Use prepare query statements
2. use implode for appending multiple values instead of foreach
3. print admin names before checkboxes
<?php
$id = $_GET['id'];
if(isset($_POST['update']))
{
$chk = implode(',', $_POST['admin_id']);
$menu_name = $_POST['menu_name'];
$menu_link = $_POST['menu_link'];
$priority = $_POST['priority'];
$sql = "update admin_menu set menu_name = '$menu_name', menu_link = '$menu_link', priority = '$priority', admin_id = '$chk' where id = '$id'";
$result = mysqli_query($link,$sql);
$msg = "";
if($result == true)
{
$msg .= "<h3 style='color:green;'>update</h3>";
}
else
{
$msg .= "<h3 style='color:red;'>Error!</h3>";
}
echo $msg;
}
$sql = "select * from admin_menu where id = '$id'";
$result = mysqli_query($link,$sql);
$row = mysqli_fetch_array($result);
$menu_name = $row['menu_name'];
$menu_link = $row['menu_link'];
$priority = $row['priority'];
$admin_id = explode(",", $row['admin_id']);
$admins = array('admin1', 'admin2', 'admin3', 'admin4', 'admin5', 'admin6', 'admin7', 'admin8');
?>
<form name="myform" method="post" >
<div class="row">
<label for="Producer_firstname">Admin Name</label>
<?php
foreach ($admins as $admin)
{
$chk = "";
if (in_array($admin, $admin_id))
{
$chk = 'checked="checked" ';
}
echo $admin.' <input type="checkbox" name="admin_id[]" value="'.$admin.'" '.$chk.'/><br/>';
}
?>
</div>
<div class="row">
<label for="Producer_firstname">Menu Name </label>
<input size="60" maxlength="255" name="menu_name" id="menu_name" value="<?php echo $menu_name; ?>" type="text" />
</div>
<div class="row">
<label for="Producer_lastname" >Menu Link </label>
<input size="60" maxlength="255" name="menu_link" id="menu_link" type="text" value="<?php echo $menu_link; ?>" />
</div>
<div class="row">
<label for="Producer_lastname" >Priority</label>
<select name="priority" id="priority">
<option value="1" <?php if($priority == 1) echo "selected='selected'"; ?>>1</option>
<option value="0" <?php if($priority == 0) echo "selected='selected'"; ?>>0</option>
</select>
</div>
<div class="row buttons">
<button type="submit" name='update' id='update'>update Menu</button>
</div>
</form>
I can not understand why the application delete the las upload.I am new in php and I hope to help me. Thank you.
Code: HTML
<div class="row">
<div class="col-md-6 col-centered">
<div class="newboxes" id="newboxes3">
<form class="form" method="POST">
<input type="text" id="nmPic" name="nmPic" placeholder="име на снимката" onfocus="this.placeholder = ''" onblur="this.placeholder = 'име на снимката'"></br>
<input type="text" id="price" class="priceFrom" name="priceFrom" placeholder="цена от" onfocus="this.placeholder = ''" onblur="this.placeholder = 'цена от'"></br>
<input type="text" id="price" class="priceTo" name="priceTo" placeholder="цена до" onfocus="this.placeholder = ''" onblur="this.placeholder = 'цена до'"></br>
<select name="picCat" id="picCat">
<option value="" selected disabled>Изберете категория</option>
<option value="Детски">Детски</option>
<option value="Сватби">Сватби</option>
<option value="Рожден ден">Рожден ден</option>
<option value="18+">18+</option>
<option value="Други">Други</option>
</select></br>
<input type="text" id="numPic" name="numPic" placeholder="номер на снимката" onfocus="this.placeholder = ''" onblur="this.placeholder = 'номер на снимката'"></br>
<input type="submit" name="showFilter" value="покажи" />
</form>
</div>
</div>
</div>
Code: php
<div class="row">
<div class="col-md-12 col-centered pic">
<form class='form' method='POST'>
<?php
if (isset($_POST["showFilter"]))
{
$picName = $_POST['nmPic'];
$priceFrom = $_POST['priceFrom'];
$priceTo = $_POST['priceTo'];
$picCat = isset($_POST['picCat']) ? $_POST['picCat'] : '';
$numPic = $_POST['numPic'];
$filter = " SELECT * FROM images WHERE status = '1'";
if ($numPic && !empty($numPic)) {
$filter .= " AND id='$numPic'";
}
if ($picName && !empty($picName)) {
$filter .= " AND img_content='$picName'";
}
if ($picCat && !empty($picCat)) {
$filter .= " AND category='$picCat'";
}
if ($priceTo && !empty($priceTo)) {
$filter .= " AND price < '$priceTo'+1";
}
if ($priceFrom && !empty($priceFrom)) {
$filter .= " AND price > '$priceFrom'";
}
$resFilter = $connect->query($filter);
if ($resFilter->num_rows > 0) {
while($row = mysqli_fetch_array($resFilter))
{
echo "<div class='col-md-3 picture'>
<img class='child-img' src='".$row["picture"]." '/></br>
<div class='number'>
<span class='id'>№ ".$row['id']."</br>
име: ".$row['img_content']."</br> категория: ".$row['category']."</br>
цена: ".$row['price']."лв.</br>
дата: ".$row['time']."ч.</br>
</span>
<input type='hidden' name='del' value=" .$row['id'].">
<input class='btn btn-danger' name='delete' type='submit' value='истрии'/>
</div>
</div>";
}
}
}
?>
</form>
</div>
</div>
<form method="POST">
<?php
if (isset($_POST['delete']))
{
$sql = "SELECT * FROM images WHERE status = '1'";
$res = $connect->query($sql);
while($row = mysqli_fetch_array($res))
{
$id = $_POST['del'];
$dbhost = 'localhost';
$dbuser = 'root';
$dbpass = 'paspartu';
$conn = mysql_connect($dbhost, $dbuser, $dbpass);
if(! $conn )
{
die('Could not connect: ' . mysql_error());
}
$sql = 'DELETE FROM images
WHERE id='.$id;
mysql_select_db('login');
mysql_query($sql);
mysql_close($conn);
}
}
?>
</form>
If pressed the delete button <input class="btn btn-danger" name="delete" type="submit" value="истрии"> , this delete the last upload image???
And can you tell me how to delete the image from upload folder "uploads/"? Thank you verry much.
It's because you don't have an input in your form that's named "showFilter". You need to either rewrite or remove:
if (isset($_POST["showFilter"]))
Try modified query delete
$sql = "DELETE FROM `your_database`.`images` WHERE `your_database`.`id` = $del_id";
As I can see your submit button is in separate form tag. That is why the button is responsible only for the first parent form and if it is pressed the page is only reloaded. It should be placed in the general form you use, so that it will be related with the general form action.
You need to take your submit button inside the form. You have used two different forms. It is the problem.
Try to write your code as below:-
<?php
// Take div and form tag outside the loop
echo "<div class='col-md-3 picture'>
<form class='form' method='POST'>";
// Loop start
while($row = mysqli_fetch_array($resFilter))
{
echo "<img class='child-img' src='".$row["picture"]." '/></br>
<div class='number'>
<span class='id'>№ ".$row['id']."
<input class='check' name='checkbox[]' type='checkbox' value='". $row['id']."'></br>
име: ".$row['img_content']."</br> категория: ".$row['category']."</br>
цена: ".$row['price']."лв.</br>
дата: ".$row['time']."ч.
</br></span>
<br></div>";
}
// Loop End
?>
<!-- submit button -->
<input class="btn btn-danger" name="delete" type="submit" value="истрии маркираните">
<?php
// end div and form tag outside the loop
echo "</form>
</div>";
if (isset($_POST['delete']) && isset($_POST['checkbox'])) {
foreach($_POST['checkbox'] as $del_id){
$del_id = (int)$del_id;
$sql = "DELETE FROM images WHERE id = $del_id";
mysql_query($sql);
}
header('Location: admin.php');
}
Hope it will help you :)
I'm trying to get my post to update just in case I make a mistake the first time around posting an article to my website.
Not sure what I'm doing wrong here.
Here is my update code:
<div class="row">
<?php
$post_title = "";
$description = "";
$id = $_GET['id'];
$result = mysql_query("SELECT title, description FROM htp_news WHERE id='$id'");
$post_title = mysql_result($result,0,"title");
$description = mysql_result($result,0,"description");
?>
<div class="row">
<form method="post" action="update-news.php">
<input type="hidden" name="ud_id" style="width: 100%" value="<? echo "$id"; ?>">
<div class="grid_12 botspacer60">
Title: <input type="text" name="ud_title" value="<?php echo "$post_title"; ?>">
<br /><br />
News Details:<br />
<textarea id="tiny_mce" name="ud_description" rows="8"><?php echo "$description"; ?></textarea>
</div>
<div class="grid_12">
<input type="submit" value="Update">
<input type="button" value="Cancel" onclick="window.location = '/admin'">
</div>
</form>
</div>
</div>
And here is my action page:
<?php
include($_SERVER['DOCUMENT_ROOT'] . "/includes/database.php");
$ud_id = $_POST['ud_id'];
$ud_title = $_POST['ud_title'];
$ud_description = $_POST['ud_description'];
// Insert record into database by executing the following query:
$query="UPDATE htp_news SET title='$ud_title', description='$ud_description' "."WHERE id='$ud_id'";
mysql_query($query);
echo "The post has been updated.<br />
<a href='edit-delete-news.php'>Update another position.</a><br />";
mysql_close();
?>
I appreciate any guidance on the matter.
Add a space before of WHERE Clause in query.
Use below -
$query="UPDATE htp_news SET title='$ud_title', description='$ud_description' WHERE id='$ud_id'";
Try this you need quotes in query
$result = mysql_query("SELECT `title`, `description` FROM `htp_news` WHERE id='$id'");
$query="UPDATE htp_news SET `title`='".$ud_title."', `description`='".$ud_description."' "." WHERE `id`='".$ud_id."'";
I am having a very hard time solving my problem with the multiple checkbox delete. Can someone direct me to the solution? What is supposed to happen here is that the user can tick the boxes and click a delete button to delete the ticked ones. Unfortunately, my code doesn't seem to work; can you point me in the right direction?
<div id="container" class="page">
<img id="disclaimer" class="page" src="images/DISCLAIMER.png" alt="" />
<img id="logo" class="page" src="images/MI-LOGO.png" alt="" />
<div id="videoContainer" class="page">
<video id="video" controls>
<source src="video/animationTest.m4v" />
</video>
</div>
<div id="etc" class="page">
<form action="<?php echo $_SERVER['PHP_SELF']?>" method="POST">
<textarea name="textPost" id="textPost">
</textarea>
<input type="submit" name="btnPost" id="btnPost" value="Post" />
<div id="displayOpacity">
<input type="text" name="display" id="display" value="0" />
</div>
<input type="submit" value="Delete" name="btnDelete" id="btnDelete" />
</div>
<div id="postItDiv" class="page">
<?php
$cxn = mysqli_connect('localhost','root','root','TimePost') or die(mysqli_error());
$selectQuery = "SELECT PostID, ClientName, VideoName, PostTime, Post, Date FROM tblTimePosts";
$selectResult = mysqli_query($cxn,$selectQuery) or die(mysqli_error());
while($row = mysqli_fetch_assoc($selectResult))
{
$postz = $row['Post'];
$timez = $row['PostTime'];
$idNoz = $row['PostID'];
echo '<div id="post1"><p class="postParagraph">Post ID No.'.$idNoz.'<br />'.$postz.' at '.$timez.' seconds mark</p><input type="checkbox" name="checkbox[]" id="checkbox[]" value="'.$idNoz.'"</input></div>';
}
if ($_POST['btnPost'] == "Post") {
$toPost = $_POST['textPost'];
$date = date("y-m-d");
$postTime = $_POST['display'];
$postTime = floor($postTime);
$insertQuery = "INSERT INTO tblTimePosts VALUES ('','Mimagazine Asia','Chelsea','$postTime','$toPost','$date')";
$insertResult = mysqli_query($cxn,$insertQuery) or die(mysqli_error());
$query = "SELECT PostID, ClientName, VideoName, PostTime, Post, Date FROM tblTimePosts";
$result = mysqli_query($cxn,$query) or die(mysqli_error());
while($row = mysqli_fetch_assoc($result))
{
$post = $row['Post'];
$time = $row['PostTime'];
$idNo = $row['PostID'];
echo '<div id="post1"><p class="postParagraph">Post ID No.'.$idNo.'<br />'.$post.' at '.$time.' seconds mark</p><input type="checkbox" name="checkbox[]" id="checkbox[]" value="'.$idNo.'"</input></div>';
}
}
else if($_POST['btnDelete'] == "Delete")
{
$tbl_name = 'tblTimePosts';
foreach ($_POST['checkbox'] as $id => $value)
{
$sql = 'DELETE FROM `'.$tbl_name.'` WHERE `PostID`='.(int)$id;
$resulta = mysqli_query($cxn,$sql);
if ($resulta > 0) {
echo "success";
}
else
echo "fail";
}
header('Location: videoJudge.php');
}
?>
</form>
</div>
<span id="copyright" class="page">Copyright © 2011<span style="color:#00AEEF;">mi</span>magazine.asia</span>
<span id="comment" class="page" style="color:#00AEEF;">comment/s</span>
<span id="download" class="page">(Right-click to download video)</span>
</div>
This HTML:
echo '<div id="post1"><p class="postParagraph">Post ID No.'.$idNoz.'<br />'.$postz.' at '.$timez.' seconds mark</p><input type="checkbox" name="checkbox[]" id="checkbox[]" value="'.$idNoz.'"</input></div>';
should be:
echo '<div id="post1"><p class="postParagraph">Post ID No.'.$idNoz.'<br />'.$postz.' at '.$timez.' seconds mark</p><input type="checkbox" name="checkbox[]" id="checkbox[]" value="'.$idNoz.'" /></div>';
This query on else if($_POST['btnDelete'] == "Delete") should be:
$sql = 'DELETE FROM `'.$tbl_name.'` WHERE `PostID`='.(int)$value;