|
Comments for: kenlin012405
| Message # 1031001: |
|
Date: 10/20/05 15:07
By: Vincent Meurink Subject: Import excel data on mysql Here is some snippet of a code that uploads tab delimited into mysql. Remember that the files needs to have the same structure as you db table. <? # first create a mysql connection here. # after that, CHANGE BELOW. $fcontents = file ('./test.xls'); # expects the csv file to be in the same dir as this script for($i=0; $i<sizeof($fcontents); $i++) { $fcontents[$i] = str_replace("'","'",$fcontents[$i]); $line = trim($fcontents[$i], '\t'); $arr = explode("\t", $line); #if your data is comma separated # instead of tab separated, # change the '\t' above to ',' $sql = "insert into TABLENAME values ('". implode("','", $arr) ."')"; mysql_query($sql); echo $sql ."<br>\n"; if(mysql_error()) { echo mysql_error() ."<br>\n"; } } ?> Cheerio |
Previous Message | Next Message |
| Comments: | ||
| how can i import any file in a php file | pkumarus | 10/15/07 22:30 |
| import excel data on mysql | deee | 02/10/06 01:51 |
| Import excel data on mysql | Vincent Meurink | 10/20/05 15:07 |
| RE: import excel data on mysql | Amal | 06/16/05 09:12 |
| Read this! | Quantum | 05/02/05 19:35 |
| Populate combo box using <for stament> | Matt | 05/01/05 14:06 |
| RE: How to export data from access to my sql | srisathiyan | 04/20/05 13:26 |
| thanks | bakwa dunks | 04/14/05 10:20 |
| How to export data from access to my sql | Leo | 04/12/05 10:06 |
| php/mysql | aamir | 04/06/05 12:43 |
| import excel data on mysql | GERARD | 04/04/05 08:50 |
| RE: php/mysql app dev | Jeremy Walker | 03/15/05 20:42 |
| RE: Need help to catch parameters in the url | Jeremy Walker | 03/15/05 20:40 |
| RE: Need help to catch parameters in the url | vicky | 03/09/05 13:46 |
| RE: Database | sriram Goteti | 03/06/05 12:19 |
| Database | Yari Tillett | 02/25/05 21:19 |
| i need help to generate database in mysql | karate devang | 02/25/05 00:27 |
| php/mysql app dev | roger leonard | 02/22/05 08:11 |
| generate coding | aishah | 02/21/05 03:02 |
| Re:php commands | Philip Dimabuyu | 02/10/05 03:19 |
| Prefer to use SQLyog | Karam | 02/09/05 23:03 |
| Need help to upload the file to server | Dayananda.MR | 02/02/05 08:25 |
| Report to Excel spreadsheets and MS Access | Dayananda.MR | 01/24/05 17:03 |
|
If you are looking for help, please post on the appropriate forum here. Your questions will be answered much more quickly. | ||


