Read data from csv file using php

Joined
Dec 16, 2006
Messages
33
Reaction score
0
Points
6
Hi guys,

What I'm trying to achieve here is a web page that will query a csv file and display data from that file. From what I've seen the way forward is using PHP.

After having trawled through Google I'm still unsure, I'm a newbie when it comes to php.

Basically I want to enter the first entry of a row from the csv file (which will be a 3 letter code) into a text box, click a 'submit' button (or press <enter> ) and then I want the web page to display the data from that row in a table or something.

Any help would be appreciated :D
 
Joined
Jun 25, 2005
Messages
3,231
Reaction score
112
Points
63
Location
On the road
Your Mac's Specs
2011 MBP, i7, 16GB RAM, MBP 2.16Ghz Core Duo, 2GB ram, Dual 867Mhz MDD, 1.75GB ram, ATI 9800 Pro vid
This can be done in any scripting or programing language. You need some programming skills to accomplish this. If you don't have any, then it is time to learn.

You would have page with the box to enter the value, pass that back to the server which would read one row at a time from your csv file, convert it, at least up the the first 'column' to plain text, and compare that to the entered value. If the value matches, convert the remaining line and pass the new table back, otherwise repeat with the next row. If multiple rows can have repeating key values, then you have to read the entire file and build up your table.

You might find a library that can read in a CVS file and convert the columns to variables to make it easier to deal with. Often the scripting language maintainers have a page for libraries you can search through.
 
OP
M
Joined
Dec 16, 2006
Messages
33
Reaction score
0
Points
6
I think I'm going to have to learn php fast as I have no idea how to string it all together.

Can anyone help further? :[
 
Joined
Dec 23, 2010
Messages
110
Reaction score
4
Points
18
Location
Vilano Beach, FL
Your Mac's Specs
MBP 15" 16/500/2.3GHz, iPad 4 32GB, iPhone 5 32GB
If this CSV doesn't change much (or even if it does for that matter), you might think about moving it into a structured database.

Then running various queries/filters/sorts would be easier and faster, and you can use existing functions for easily handling your data.

So you could either import it manually (in the case where it doesn't change [often]), or use a browse/upload control to select a local file, move it to the server, parse it, drop it into a DB.

In terms of "how", that's probably a larger post than this MB supports :D

Have fun!
 

Shop Amazon


Shop for your Apple, Mac, iPhone and other computer products on Amazon.
We are a participant in the Amazon Services LLC Associates Program, an affiliate program designed to provide a means for us to earn fees by linking to Amazon and affiliated sites.
Top