Jump to content

upload an excel or text file into SQL table


ashworthm

Recommended Posts

Hi everyone, i am very new to php and sql. I am having trouble in getting a script to upload info into my sql table. I have got an upload form sorted but just cannot get my hands on a script to load the data into the sql table. Does anyone have one that i can just alter the fields?
any help will be welcomed.

thanks
Hello,

I am a little unsure of how your question relates to the table but here goes,

If you have an html form which accepts user input via textboxes etc you can pass these to PHP and then use SQL statements to insert this data into a database.

If you have an html form which uploads a file you will then need to create a script which can read the file, best formats are CSV, XML or even plain text but that gets messy and then you can pass this data to a database again via SQL statements.
Your still confusing me, lets work through what you say you have.

1. You have a table in SQL with rows of data, is this in your MySQL database?
2. You have a text file, containing what? what is the text file? what is it for?
3. You want the physical text file in the table? OR you want the data in that text file in the table or a new table?
4. Which MySQL screen are we talking? Do you mean the command line interface on MySQL server? or are you referring to PHPMyAdmin?
hi,
1.yes, i have a table in mysql database with rows setup but no info in them yet.
2.i have a comma delimited text file which i want to upload into the sql database
3.i want the contents of the text file in the sql database
4.the sql screen i mentioned was phpmyadmin.

hope this helps
In console:

1. upload the CSV via ftp
2. login to mysql
3. issue command:
[code]LOAD DATA LOCAL INFILE "/path/to/csv/file"
INTO TABLE `table`
FIELDS TERMINATED BY ","
LINES TERMINATED BY "\r\n";[/code]

Via the web:

1. use phpmyadmin: http://www.phpmyadmin.net/home_page/index.php

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.