Is there a way to take a spreadsheet and import it into a mysql database?
thanx
| SitePoint Sponsor |




Is there a way to take a spreadsheet and import it into a mysql database?
thanx


I don't know the step by step instructions, but I have done it before with a spreadsheet, it had 400 lines and 14 colums. It took me awhile to get it prepared to dump into a database,
But if you can export that spreadsheet into a text file then there ya go! Go to mysql.com and look for "LOAD DATA INFILE" that should explain it



You either need to create a custom PHP script to parse a tab (or whatever) delimited file and insert each row into the database, or you can use phpMyAdmin. I highly recommend using a custom script, since phpMyAdmin can be finicky at times.
Blamestorming: Sitting around in a group discussing why a deadline was missed or a project failed and who was responsible.
Exbabylon- Professional Internet Services




is there a tutorial out there that could help me with this problem?



Not that I know of. If you know PHP then it's really not a problem.
PHP Code:$var = "1,2,3,4,6,6,7,8,9";
$line = explode("\n", $var);
foreach($line as newline){
$newline = explode(",", $newline);
$sql = "INSERT INTO table SET 1='$newline[0]', 2='$newline[1]"
if(!mysql_result($sql){
echo("Database Error");
exit();
}
}
Blamestorming: Sitting around in a group discussing why a deadline was missed or a project failed and who was responsible.
Exbabylon- Professional Internet Services
I would try and export the spreadsheet as a CSV file (comma seperated values) and use LOAD DATA INFILE. The MySQL manual explains this well.
Bookmarks