alhakimy Posted March 10, 2018 Share Posted March 10, 2018 I use google for translation I have this code <?php //step one connect with database $connect = new mysqli ("localhost","root","0220","test"); ?> <?php // insert step $id=$_POST['id']; $name=$_POST['name']; $pass=$_POST['pass']; $sql = "INSERT INTO users (id, name, pass)VALUES ('$id', '$name', '$pass')"; if($_POST['enter']) { // not null text if(empty($id)||empty($name)||empty($pass)){ echo "You did not enter the required fields."; die; } if ($connect->query($sql) === TRUE) { echo "New record created successfully"; } else { echo "Error: " . $sql . "<br>" . $connect->error; }} ?> <?php //step 2 the select query $qur = "select * from users"; $result = mysqli_query($connect, $qur); If ( ! $result ){ Die ("error in query"); } ?> <?php //step 3 show the data echo "<table border='1'>"; While ($row= mysqli_fetch_assoc($result)){ Echo "<tr><td>".$row["id"]."</td><td>".$row["name"]."</td><td>".$row["pass"]."</td><td><a href='delete?id=".$row["id"]."'>del</a></td></tr>";} echo "</table>" ?> Makes like the attached picture what should I do To delete the record When pressed Del thank you Link to comment Share on other sites More sharing options...
justsomeguy Posted March 12, 2018 Share Posted March 12, 2018 On your delete page, you can access $_GET['id'] to get the ID that you passed in the URL. You can either delete immediately, or show a confirmation page to make sure they meant to do that, or whatever you'd like to do. With the database ID you can just use a regular delete query to delete the record with that ID. Link to comment Share on other sites More sharing options...
alhakimy Posted March 14, 2018 Author Share Posted March 14, 2018 Thank you justsomeguy Now when the deletion process Do not delete directly when press the Delete But after pressing Refresh the page is deleted Link to comment Share on other sites More sharing options...
justsomeguy Posted March 14, 2018 Share Posted March 14, 2018 If you need help with your code, we'll need to see the actual code you're using for the delete page. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now