Help with PHP Delete SQL record

I am having a hard time getting a simple “delete” function working on my app. Here is the code I have in

delete.php

<?php include("assets/includes/config.php"); if(isset($_GET['job_number']) && $_GET['job_number'] !='') { $JOB_NUMBER = $_GET['job_number']; $result = mysqli_query($conndb,"SELECT * FROM `master` WHERE `JOB_NUMBER` = $JOB_NUMBER") or die(mysqli_error($conndb)); $_SESSION['success'] = 'Job deleted successfully!'; header("Location: jobs.php"); } ?>

This is the cose for my “delete” button on my records page (jobs.php):



When I click the “delete” button, I get the confirmation to ok the delete, I click OK, then the browser goes to

domain.com/delete.php?job_number=

I don’t understand what is going wrong. My primary AI field in my database is “JOB_NUMBER” not “id”

Any advise is greatly appreciated.

Your problem is quite obvious. You are selecting the record rather than deleting it.

$result = mysqli_query($conndb,“SELECT * FROM master WHERE JOB_NUMBER = $JOB_NUMBER”) or die(mysqli_error($conndb));

Sponsor our Newsletter | Privacy Policy | Terms of Service