Answers for "how to delete all data from table in php"

PHP
1

how to delete all data from table in php

DELETE FROM table_name;<?php 

$servername = "localhost";
$username = "root";
$password = "";
$dbname = "game";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
  die("Connection failed: " . $conn->connect_error);
}

// sql to delete a record

$sql = "DELETE FROM data";

if ($conn->query($sql) === TRUE) {
  echo "Record deleted successfully";
} else {
  echo "Error deleting record: " . $conn->error;
}

$conn->close();

?>
Posted by: Guest on April-24-2022
0

deleting a row from databse using php

if (isset($_GET['del'])) {
	$id = $_GET['del'];
	mysqli_query($db, "DELETE FROM info WHERE id=$id");
	$_SESSION['message'] = "Address deleted!"; 
	header('location: index.php');
}
Posted by: Guest on January-24-2021

Code answers related to "how to delete all data from table in php"

Browse Popular Code Answers by Language