check it out [on github](https://gist.github.com/customanything/5906840).
Tested. Commented; ask anything.
>Plus, I have no idea what most of that means. Haha
>However, I disagree with putting the query inside the loop: that’s a lot of queries, each requiring a new call to the DB, which takes a lot of time. Instead, you can use your loop to parse/organize all your data, and then do a single query to insert at the end.
“don’t put stuff in loops if you don’t have to.”
>You should use PDO to connect.
`ext/mysql` (all the `mysql_*()` functions) is deprecated and will be removed from PHP in the future. It’s been outdated for many years anyway. You should use [PDO](http://php.net/pdo) or [MySQLi](http://php.net/mysqli) instead.
(Where your data comes from is not relevant.)