Created
January 20, 2026 20:26
-
-
Save maxixo/a23c3b074585eb9706bd2594bec1d2c1 to your computer and use it in GitHub Desktop.
updating and deleting in sql
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Updating data | |
| $newName = "Alice smith "; | |
| $idToUpdate = 3; | |
| $sql = "UPDATE users_ SET name = '$newName' WHERE id=$idToUpdate"; | |
| if ($conn->query($sql)) { | |
| echo "Record Updated"; | |
| } else{ | |
| echo "Update failed"; | |
| } | |
| //Remove data | |
| $idToDelete = 4; | |
| $sql = "DELETE FROM users_ WHERE id=$idToDelete"; | |
| if ($conn->query($sql)) { | |
| echo "user Deleted"; | |
| } else { | |
| echo "Delete failed "; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment