PDA

View Full Version : PHP - form to add data to middle of existing csv file



hil_egg
05 Jul 2010, 07:04 PM
Hi

I am very new to programming and I've just spend a whole day searching the internet for answers that I can comprehend and I can't find any.

I have a csv text file that records a serial number on bottle thrown into the ocean, and the coordinates of the location that the bottle was thrown in such as

serial#1, lat_drop#1, long_drop#1
serial #2, lat_drop#2, long_drop#2
serial #3, lat_drop#3, long_drop#3
etc...

I am trying to make a form on the internet where someone can report FINDING a bottle.

I want them to be able to type in the serial number of the bottle, and the coordinates where they found the bottle, and I want this to be added to my csv file as such

serial#1, lat_drop#1, long_drop#1
serial#2, lat_drop#2, long_drop#2, lat_found#2, long_found#2
serial#3, lat_drop#3, long_drop#3

So my question is, how do i get php to write to my text file not at the END, but in the row that has the specified serial number, after the existing data in that row?

Is this even possible?

Should i look into learning "xml" instead of trying to deal with my data in csv files and excel like I am now?