Hi, I have a CSV file that looks like the following...
TVWB09285~28 Dec 2007 13:57~DARRELL LITCHFIELD~THE JNP PARTNERSHIP~Address Line 1~-~HIGH WYCOMBE~Mainland UK~-~HP13 6LJ~DARRELL LITCHFIELD~01234567890~-~-
~1~0~dl@xx
x.co.uk~~U
NI PLASMA TILT~phone order~~
TVWB09283~28 Dec 2007 13:16~Barbara Thomas~C P M~Address Line 1~Warrington~Mainland UK~-~WA4 6QS~Barbara Thomas~01234567890~C P M~-~3~0~barbara.thomas@xxx
.com~~TV-F
MEGA~~~
TVWB09282~28 Dec 2007 13:14~m gunn~~Address Line 1~-~Forres~Mainland UK~-~IV36 2US~m gunn~01234567890~-~-~1~0~b
illthebike
@gmail.com
~~TVW-33~~
~
TVWB09281~28 Dec 2007 13:15~Mr B Andrews~~Address Line 1~-~Orpington~Mainland UK~-~BR6 8PD~Mr B Andrews~01234567890~-~-~1~
0~barrysan
dya@google
mail.com~~
TVW-32~~~
TVWB09280~28 Dec 2007 13:12~Mr Oliver~Cassis~Address Line 1~-~Broadstairs~Mainland UK~-~CT10 3QY~Mr Oliver~01234567890~Cassis~
-~1~0~dave
@xxx.com~~
TVW-34~pho
ne order~~
I need to enter this data into a MySQL database in a single fell swoop. On the above data I have separated each separate "row" the a line space. Obviously, in all realism, there won't be a line space within the CSV. However, if required, I am able to add a special character before the order number (TWVB0XXXX) in order to make this clarification possible.
So I have created my database with the following fields, which the above data needs to be inserted into, in the order specified...
ref_id
order_number
date
name
company_name
address1
address2
towncity
county
na1
postcode
deliveryname
telephone
companybackup
na2
items
na3
email
na4
bagsize
weight
deliveryinstructions
na5
Can anyone help me do this. I am good at basic level PHP, but when it gets to doing functions within functions, which this appears to be, this is where I get awful confused and mixed up.
I am assuming (maybe incorrectly) I have to explode the above data, into each row required to be added - and then I need to explode each row with the ~ charatcer in order to insert it into the DB.
I just dont know how to do it! Any help appreciated :)
Start Free Trial