-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcreateTable.php
More file actions
41 lines (33 loc) · 1.11 KB
/
createTable.php
File metadata and controls
41 lines (33 loc) · 1.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
<html>
<head>
<title>Creating MySQLi Tables</title>
</head>
<body>
<?php
$host = 'localhost';
$user = 'souban';
$pass = 'MySQL_m_l_0';
$dbname = 'TUTORIALS';
$conn = mysqli_connect($host, $user, $pass,$dbname);
if(!$conn){
die('Could not connect: '.mysqli_connect_error());
}
echo 'Connected successfully<br/>';
$vara="lolsterrr";
$CheckTable = mysqli_query($conn,"SHOW TABLES LIKE '".$vara."'");
$sql = "create table " . $vara . "(
id INT AUTO_INCREMENT,param TINYINT NOT NULL,primary key (id))";
if( mysqli_num_rows($CheckTable) > 0 ) echo 'Table exists';
else{
echo 'table does not exist';
if(mysqli_query($conn, $sql))
{
echo "Table created successfully";
} else {
echo "Table is not created successfully ";
}
}
mysqli_close($conn);
?>
</body>
</html>