I want the exact opposite of this.
I want to load a .xls file full of emails into a database column.
What's the simplest way to do this?
I want the exact opposite of this.
I want to load a .xls file full of emails into a database column.
What's the simplest way to do this?
Like Ponies said, you will have to first "Save As > CSV" then upload and do whatever. Often permissions will not allow that SQL statement however. My personal favorite is using csv2sql.com because it will do the heavy lifting and give you the SQL to just execute, however you could use fgetcsv which would be more secure, and something you can implement into a script.
With fgetcsv, you could do something like this assuming you just had a one column file with the email addresses listed:
$row = 1;
if (($handle = fopen("test.csv", "r")) !== FALSE) {
while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
$num = count($data);
//echo "<p> $num fields in line $row: <br /></p>
";
$row++;
for ($c=0; $c < $num; $c++) {
if ($c==0){
//This is the first column
//Just run a generic MySQL insert command here (see below for link for more info on this)
}
}
}
fclose($handle);
}
Tutorial on PHP MySQL Insert: at W3Schools. That should get you going on this endeavor.