Automatically add fields/columns to a MySQL database

To take the fields from a form and build a database on the fly do the following:

foreach($_POST as $var => $value)
{
$squery = "ALTER TABLE `table_name` ADD COLUMN `$var` varchar(255)";
// then run query here
}

About Keiron

Web Developer based in the UK. Click here if you want to work with me