The record inside mysql not deleted

<?php
include 'config.php';
?>
<!DOCTYPE html>
<html>
<head>
<title>File Uploading With PHP and MySql</title>

<link rel="stylesheet" href="style.css" type="text/css" />
</head>
<body>
<div id="header">
<label> Delete by date </label>
</div>
     <br /><br />
   <form action="index.php" method="post" enctype="multipart/form-data">
   <button type="submit" name="btn-main" style="height: 25px; width: 200px">MAIN PAGE</button>
    </form>
	     <br /><br />
<form>
<div id="body">
<input type="date" name="dd" placeholder="YY-MM-DD" required />
<input type="submit" name="delete" value="Submit"/>
</form>

<br/><br/>

</body>
</html>
<?php 

if(isset($_POST['delete']))
{

$date = $_POST['dd'];

  // mysql delete query 
    $query = "DELETE FROM nov WHERE date = $date";
    
         if(mysqli_query($db, $query)) {  
    
                       ?>
  <script>
  alert('successfully delete date');
        window.location.href='index.php?success';
        </script>
  <?php
    }else{
                       ?>
  <script>
  alert('failed delete date');
        window.location.href='index.php?success';
        </script>
  <?php
    }
    mysqli_close($db);
}

      
?>

Open in new window


The record not delete when i put date, anyone know any mistake over there , I tried change again and again still same .
Scott Yong Asked:
Who is Participating?
 
Ryan ChongConnect With a Mentor Commented:
missing the quotes? quick try:

$query = "DELETE FROM nov WHERE date = '$date'";
1
 
Ryan ChongCommented:
it seems that your php scripts only delete the record in MySQL and regardless of what condition, it's not deleting the file (no delete file scripts found in the php scripts...)
1
 
Scott Yong Author Commented:
ya i edit the question first , i want to delete the record inside mysql hehe
0
 
Scott Yong Author Commented:
OMG its work .. I do the minor mistake then its failed LOL. Thanks for help
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.