I am trying to add a new column to a table with a set date as the column head and a tinyint(1) as the datatype
function addAttendance($date) {
include('connection.php');
$column_name = strtolower($date);
if(!preg_match('/[^A-Za-z0-9.#\\-$]/', $column_name)){
if(!empty($column_name)) {
$st = $db->prepare("DESCRIBE attendance");
$st->execute();
$st = $st->fetchAll(PDO::FETCH_COLUMN);
$compare = $st;
foreach($compare as $key) {
if($key === $column_name) {
die('Project name already exists. Please select a different name.');
}
}
$st = $db->prepare("ALTER TABLE attendance ADD $column_name BOOLEAN");
$st->execute();
} else { die('Project name is empty.');}
} else { die('Project name can only contain letters and numbers.');}
}