views:

84

answers:

1

i want to import .txt file values into mysql using php and jquery/Ajax without page refresh.

with following format.

for example text file is :

       user@emaill;user name;gender
       user1@emaill;user name;gender
       user2@emaill;user name;gender

user select file and press Process Button. once it start processing JQUERY/AJAX shows

      you have 3 records
      processing Record no.1 user@email
      ..................................
      ..................................
      Import Process Complete

does any one work on same example.

i search on net but didn't find any example. many examples for picture upload but not for import data from text file.

Thanks

+1  A: 

Forget about jQuery. I don't see it playing any role at all for this job.

Just do a POST to send the data to your PHP script. There, let PHP write it to a file and do LOAD DATA INFILE (http://dev.mysql.com/doc/refman/5.1/en/load-data.html).

Altertnatively, if you don't want to copy the data to a file, use fgetcsv() (http://nl2.php.net/manual/en/function.fgetcsv.php) to parse the lines and fields, and generate SQL statements so you can store it in MySQL

Roland Bouman
Agree. When importing data, animation don't play any important role in it. Forget making it looks like the sci-fi movies and just make sure it import the data correctly. No user do import data in daily work base, usually this only done when migrating the system or installing new system then import any old data. This kind of task usually done by admin, not regular user.
Donny Kurnia