I am trying to add a new column to my MYSQL table using PHP. I am unsure how to alter my table so that the new column is created. In my assessment table I have:
Something like:
$db = mysqli_connect("localhost", "user", "password", "database"); $name = $db->mysqli_real_escape_string($name); $query = 'ALTER TABLE assesment ADD ' . $name . ' TINYINT NOT NULL DEFAULT \'0\''; if($db->query($query)) { echo "It worked"; }
Haven't tested it but should work.