Skip to content

Instantly share code, notes, and snippets.

@maxixo
Created January 20, 2026 20:26
Show Gist options
  • Select an option

  • Save maxixo/a23c3b074585eb9706bd2594bec1d2c1 to your computer and use it in GitHub Desktop.

Select an option

Save maxixo/a23c3b074585eb9706bd2594bec1d2c1 to your computer and use it in GitHub Desktop.
updating and deleting in sql
// 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