My Update.php
file:
<?php ob_start();
session_start();
//declare the basic variables
$servername = "localhost";
$username = "bilal";
$password = "super";
$dbname = "coursework";
//create connection
$link = mysqli_connect($servername, $username, $password, $dbname);
//check connection
if($link->connect_error){
die ("connection failed: " . $link->connect_error);
}
//Security purpose, handiling escape string
// $crested_by = $_POST ['created_by'];
$title = $_POST['title'];
$catagory = $_POST['catagory'];
$contact = $_POST['contact'];
$comment = $_POST ['description'];
$ses = $_SESSION['email'];
$date = date('Y-m-d');
$availability = $_POST ['availability'];
$price = $_POST ['price'];
$id = $_POST['wow'];
// $created_by_id = $_SESSION['created_by_id'];
// $username = $_SESSION['firstname'];
if (isset($_POST['del'])){
$deletequery=mysqli_query($link,"DELETE FROM new_post WHERE id='$id'");
header ("Location: added_posts.php");
}
else if(isset($_POST['update'])){
$sql = "UPDATE new_post SET title='$title', contact='$contact', availability='$availability', price='$price', comment='$comment' WHERE id='$id'";
if (mysqli_query($link, $sql)){
echo "awesoke";
header("Location:added_posts.php");
}else{
echo "Error: Sign up Unsuccessfull";
}
}
$link->close();
?>
This is my update.php
file I am showing the id
inside as textbox
and the doing where id = the text field value
. It is deleting but the recently added item deletes like if i have 3 posts id like ( 4, 5, 6) id delete the 6 first then 5 then 4. I am displaying data in bootstrap cards. but every delete button under post it delete the recent one which is recently added.