April 22, 2018

How to Create or DROP TABLE in MySQL

freewaredownload.in free PHP MYSQL SCRIPTS

FREE PHP SCRIPT SOURCE CODE

PHP SCRIPT SOURCE CODE FREE

PHP CREATE TABLE QUERY

PHP – HOW TO CREATE TABLE IN MYSQL USING A QUERY



CREATE TABLE ADMISSION
(
PID int,
LastName varchar(255),
FirstName varchar(255),
Address varchar(255),
City varchar(255)
)


PHP DROP TABLE SQL QUERY


// This will delete the table with all the data inside it
DROP TABLE table_name

// This will delete the data inside leaving the Table structure intact
TRUNCATE TABLE table_name

PHP CREATE / DROP / TRUNCATE SQL QUERY


// Create a new Database
CREATE DATABASE database_name

// Drop a Database, this will delete the DB with all records in side
DROP DATABASE database_name

CREATING TABLE THROUGH PHP SCRIPT (Save as create_table.php)



<?
02

//the example of making MySQL database table
// You need to upload this script on web server and call in browser.
// First it will create a DB and then a Table with fields

03
//create_table.php

04
$continued = mysql_connect("localhost","username","password");
05
if($continued){
06
    echo("Connection is succeed");
07
}else{
08
    echo("Connection is fail");
09
}
10
$make = mysql_create_db("employees");
11
if($make){
12
    echo("<br><br>Employees database succeeds in making");
13
}else{
14
    echo("<br><br>Employees database fails in making");
15
}
16
$order1 = "CREATE TABLE data_employees

17
    (
18
        employees_number int(10)AUTO_INCREMENT PRIMARY KEY,
19
        name char(100),
20
        address varchar(255)
21
    )";
22
$make_table = mysql_db_query("employees",$order1);
23
if($make_table){
24
    echo("<br><br>Table data_employees succeeds in making");
25
}else{
26
    echo("<br><br>Table data_employees fails in making");
27
}
28
?>



Developers Homepage Download Free now

 FREE PHP CODE

PHP Script Description:

SQL

In CREATE TABLE QUERY the PID column is of type int and will hold a number. The LastName, FirstName, Address, and City columns are of type varchar with a maximum length of 255 characters. You need to RUN this query to create a MySQL Table with certain fields as defined.

Note: Copy the Source Code to Notepad or any other good Text Editor and save as .php or .html or .css as the case may be. Give your own file name, if not described in the script.

SQL

RELATED FREEWARES

[catlist id=18]
[catlist id=5]

::