Search
 
SCRIPT & CODE EXAMPLE
 

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

?>
Comment

PREVIOUS NEXT
Code Example
Php :: time zone set in codeigniter 
Php :: composer 
Php :: php install xdebug mac 
Php :: wordpress global variable not working 
Php :: check file selected in php 
Php :: laravel blade route redirect back 
Php :: Numbers Formater Decimal & Thousand Separator PHP 
Php :: php prime numbers 
Php :: why laravel site loading only 
Php :: php subtract date from today 
Php :: show query in laravel 
Php :: laravel difference between current time and created time 
Php :: laravel storage save file folder on disk 
Php :: laravel migration with primary key 
Php :: laravel update and insert transaction 
Php :: laravel if database has table 
Php :: php hash password using bcrypt 
Php :: php get and print file contents 
Php :: Laravel validating birthdate by 13 years old 
Php :: php hash password 
Php :: how send parameter with command in laravel 
Php :: php increment letter 
Php :: sanitize_text_field 
Php :: php session time out default 
Php :: laravel sort by numbers 
Php :: laravel validate file type 
Php :: program-generate-random-alphabets using php 
Php :: woocommerce check if user is logged in 
Php :: strval in php 
Php :: laravel validation unique if this field is changed 
ADD CONTENT
Topic
Content
Source link
Name
2+6 =