0

I've been searching and searching and I'm sure I'm just looking up the wrong thing so I'm looking for a push in the right direction please.

I'm a newbie to PHP and MySQL and my first project has a need to upload excel sheets that contain 20k or so records at varying intervals to an already existing MySQL database. I understand how to do a simple upload and map fields but where I am getting stuck is the excel data is going to two separate tables and the second table has a foreign key for the first table.

I need to find out if the record is a duplicate in table one and if so, get the primary key and insert it into the second table along with some data from the excel sheet.

I'm sure what I'm asking for is very basic but I need to know what the most accepted way to do this is so I can research and build it. I'm not sure if CRUD is what I'm looking for or if I should be running a special SQL statement in PHPMyAdmin?

Im using PHP, MySQL, Godaddy shared hosting for this project. Thx!

1 Answer 1

2

Look at PHPExcel for dealing with Excel data - http://phpexcel.codeplex.com/

Sign up to request clarification or add additional context in comments.

5 Comments

Looks like it will be helpful for manipulating excel data but not as helpful for loading it into MySQL and running PHP code on it beforehand which is what I need advice on here.
Erm, why wouldn't you just read the file and parse it like you would any other file? Parse the file and write the insert query, once you parse the file you can do what ever you want to it. I figured you were just looking for a way to read the file correctly...
I guess thats my question. I know how to manipulate data already in MySQL, how do I get it in from the outside not using PHPMyAdmin? Do I create a private webpage with an upload link and have a script manipulate it once uploaded? Sorry such a basic question but I'm new to this and just not sure what everyone else is doing for this. Thx.
So you're going to want to look at handling file uploads and the using PHP Data Objects (PDO) to connect to your MySQL server and add the data in that way. PDO - php.net/manual/en/book.pdo.php File Uploads - tizag.com/phpT/fileupload.php and then the link I sent for PHPExcel should give you some insight on how to use that library. Hope that is helpful
I guess its that easy. Not sure why I was making it so hard. Thx!

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.