I would like your help with something that I have searched a lot but could't yet find an answer. As the title of the Question states, I am trying to create a table in mySql database in which I do not know the data types of the columns. Basically, I use php to create new tables in my database from an csv file. The first line contains the column names. I know that it can be done because I have seen it in phpMyAdmin where I can select a csv file and use the first line to generate the table column names and I do not have to specify the data types of each column,
So far, this is my php code :
$databaseName="myDatabase";
mysql_connect("localhost","xxxxxx","xxxxxxxx");
mysql_select_db($databaseName);
for($i = 0; $i < count($newFiles); $i++){//traverse the table that contains the file names
$content = file($newFileLocation.$newFiles[$i]);
//First line: $content[0];
$firstLine=$content[0];//save first line which are the column names
//echo $firstLine;
$tableName= str_replace('.txt','', $newFiles[$i]);//remove the .txt to use for table name
//echo $tableName."\n";
echo "\n\ncreating tables\n\n";
/*mysql_query("load data local infile '$newFiles[$i]'
into table $tableName
fields terminated by ','
lines terminated by '\n'
($firstLine) "); */
mysql_close();
}