New To Mac-Forums?

Welcome to our community! Join the discussion today by registering your FREE account. If you have any problems with the registration process, please contact us!

Get your questions answered by community gurus Advice and insight from world-class Apple enthusiasts Exclusive access to members-only contests, giveaways and deals

Join today!

 
Start a Discussion
 

Mac-Forums Brief

Subscribe to Mac-Forums Brief to receive special offers from Mac-Forums partners and sponsors

Join the conversation RSS
Web Design and Hosting Creating sites, scripting, and hosting discussions.

Read data from csv file using php


Post Reply New Thread Subscribe

 
Thread Tools
Mbengi Bongi

 
Member Since: Dec 16, 2006
Posts: 25
Mbengi Bongi is on a distinguished road

Mbengi Bongi is offline
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
QUOTE Thanks
xstep

 
xstep's Avatar
 
Member Since: Jun 25, 2005
Location: On the road
Posts: 3,231
xstep is a name known to allxstep is a name known to allxstep is a name known to allxstep is a name known to allxstep is a name known to allxstep is a name known to allxstep is a name known to all
Mac Specs: 2011 MBP, i7, 16GB RAM, MBP 2.16Ghz Core Duo, 2GB ram, Dual 867Mhz MDD, 1.75GB ram, ATI 9800 Pro vid

xstep is offline
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.

CameraTime - Time lapse photography for novice and advanced users.

When asking questions, post the version of your software. You'll receive better answers.

Please post your results to the thread as it is good feedback.
QUOTE Thanks
Murlyn

 
Murlyn's Avatar
 
Member Since: Jun 11, 2003
Location: Mount Vernon, WA
Posts: 4,909
Murlyn is a name known to allMurlyn is a name known to allMurlyn is a name known to allMurlyn is a name known to allMurlyn is a name known to allMurlyn is a name known to allMurlyn is a name known to all
Mac Specs: MacBook Pro 2.6 GHz Core 2 Duo 4GB RAM OS 10.5.2

Murlyn is offline
A couple php functions that you might want to look into:

PHP: fgetcsv - Manual
PHP: print_r - Manual

Also your post variables will be found in the $_POST array
QUOTE Thanks
Mbengi Bongi

 
Member Since: Dec 16, 2006
Posts: 25
Mbengi Bongi is on a distinguished road

Mbengi Bongi is offline
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?
QUOTE Thanks
phpguy

 
Member Since: Jun 26, 2011
Posts: 1
phpguy is on a distinguished road

phpguy is offline
Reading CSV data using PHP is fairly easy. You can use fgetcsv to do this.
Here is one example to read CSV file using PHP.

Hope this helps!
QUOTE Thanks
[DT]

 
[DT]'s Avatar
 
Member Since: Dec 23, 2010
Location: Vilano Beach, FL
Posts: 110
[DT] has a spectacular aura about
Mac Specs: MBP 15" 16/500/2.3GHz, iPad 4 32GB, iPhone 5 32GB

[DT] is offline
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

Have fun!
QUOTE Thanks

Post Reply New Thread Subscribe


« Popular key words | PHP can't connect to mySQL database »
Thread Tools

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off
Forum Jump

Similar Threads
Thread
Thread Starter
Forum
Replies
Last Post
Importing CSV File into Address Problems! oleviking Switcher Hangout 6 06-08-2008 06:39 AM
Archive and Install question andrebnu OS X - Operating System 6 10-30-2007 09:16 PM
new MacBook: Turbotax can't open file azed Switcher Hangout 2 09-11-2007 02:05 PM
JPEG file download via PHP on Mac(IE) irobot Web Design and Hosting 1 03-09-2005 09:40 PM
Scripting a cron job to post data to a url via variable lizardthefish OS X - Development and Darwin 4 02-14-2004 04:33 PM

All times are GMT -4. The time now is 08:42 AM.

Powered by vBulletin
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
X

Welcome to Mac-Forums.com

Create your username to jump into the discussion!

New members like you have made this community the ultimate source for your Mac since 2003!


(4 digit year)

Already a member?