Skip to content

Instantly share code, notes, and snippets.

@shihchun
Last active May 9, 2018 02:14
Show Gist options
  • Save shihchun/27c5f909dc21745628e45d74630b6ae1 to your computer and use it in GitHub Desktop.
Save shihchun/27c5f909dc21745628e45d74630b6ae1 to your computer and use it in GitHub Desktop.
<?php
// database connection
$servername = "localhost";
$username = "root";
$password = "";
$conn = new mysqli($servername, $username, $password);
if ($conn->connect_error) {
die("Connection failed:" . $conn->connect_error);
}
/***************************************************/
//Create database for members
$sql = "CREATE DATABASE IF NOT EXISTS members";
if ($conn->query($sql) === TRUE) {
echo "Database members created successfully";
} else {
echo "Error creating database members:" . $conn->error;
}
// make bopp the current db
$dbname = "members";
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed:" . $conn->connect_error);
}
// create empolyee table
$sql = "CREATE TABLE IF NOT EXISTS empolyees (
id INT(6) UNSIGNED AUTO_INCREMENT PRIMARY KEY,
badge_num VARCHAR(30),
fullname VARCHAR(30) ,
firstname VARCHAR(30) NOT NULL,
lastname VARCHAR(30) NOT NULL,
gender VARCHAR(30) NOT NULL,
birth_date VARCHAR(30) NOT NULL,
department VARCHAR(30) NOT NULL,
position VARCHAR(30),
epc VARCHAR(30) NOT NULL,
Image longblob,
regist_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP
)";
if ($conn->query($sql) === TRUE) {
echo "Table empolyee created successfully";
} else {
echo "Error creating table bopp:" . $conn->error;
}
/***************************************************/
// ended connection
/***************************************************/
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment