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:
$table = 'your table name';
$column = 'q6'
$add = mysql_query("ALTER TABLE $table ADD $column VARCHAR( 255 ) NOT NULL");
you can change VARCHAR( 255 ) NOT NULL
into what ever datatype
you want.
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.