Hey there again,
For this post I’ll teach you how to make an automatic deleting system and the concept that we’ll use is the same concept that we used in insert add-ons and update add-ons. So, there are two pages of code that we’ll need to do this. So, try them on your own first and then read my explanation.
<form action=”dplay2.php” method=”POST”>
Delete the staff with the StaffID <input type=”text” name=”id”>
Since you’ve did this with me a couple of times already, I’ll just provide you a brief explanation of what’s happening here.
1. This is just a form to send the Staff ID of who we want to delete, since the Staff ID is like the code to differentiate the employees in a company.
2. <p></p> is a paragraph tag which means everything in it will be in paragraphs.
$id = $_POST[‘id’];
$conn = mysqli_connect(“localhost”,”root”,””,”company”);
$delete = “DELETE FROM staff WHERE StaffID=$id”;
echo “Succesfully deleted”;
echo “Unsuccessful” . mysqli_error($conn);
1. This is the backbone of the system and where the process is done.
2. $conn = mysqli_connect(“localhost”,”root”,””,”company”);
– the 1st “” is for your type of server
– the 2nd “” is for your username to enter phpMyAdmin
– the 3rd “” is for the password
– the 4th “” is the database name and since the database that we’ve created before is called company, we put company inside the “”.
So, that is all for SQL Series. I hope you learnt a lot from this simple tutorial. As the SQL Series is finished, there’ll only be new posts on Monday and Thursday. So, keep your eyes open!
Any inquiries, mail me at firstname.lastname@example.org