8000 Create create_database.php · Abhijeetbyte/SQLite-PHP-Database@bcabdbc · GitHub
[go: up one dir, main page]

Skip to content

Commit bcabdbc

Browse files
authored
Create create_database.php
1 parent 7f71f5f commit bcabdbc

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

create_database.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?php
2+
// Create (connect to) SQLite database in file
3+
$db = new PDO('sqlite:students.db');
4+
5+
// Set errormode to exceptions
6+
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
7+
8+
// Create table
9+
$db->exec("CREATE TABLE IF NOT EXISTS Attendance (
10+
id INTEGER PRIMARY KEY,
11+
roll_no TEXT,
12+
student_name TEXT,
13+
date TEXT
14+
)");
15+
16+
echo "Database and table created successfully.";
17+
?>

0 commit comments

Comments
 (0)
0