Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

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();

?>
 
PREVIOUS NEXT
Tagged: #delete #data #table #php
ADD COMMENT
Topic
Name
8+9 =