Grouping data

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
S_henry
Forum Contributor
Posts: 148
Joined: Sun Jan 25, 2004 10:25 pm
Location: M'sia

Grouping data

Post by S_henry »

Let say I have the records of students (name, address, phone no, course etc..) in a cd. This record let say in MS Excel format. I want to extract all the records into my system and automatically put all the records into their group. In my system, I have 4 group :Town A, B, C and D. I want the system put all the students record into their group base on their location (which town) automatically from the data on the cd. Anybody get the idea how to make this?
fastfingertips
Forum Contributor
Posts: 242
Joined: Sun Dec 28, 2003 1:40 am
Contact:

Post by fastfingertips »

First you should load that excel file in a proper structure (parse it) the you will be able to insert this info were you need. Unfortunatelly almost this scripts are paid ones but you may try on sourceforge.

Other method is to convert the Excel to XML and from XML will become just a child play.
Grim...
DevNet Resident
Posts: 1445
Joined: Tue May 18, 2004 5:32 am
Location: London, UK

Post by Grim... »

Start by using excel to save as a comma delimited file. Then use PHP to read through the file, copying each student out into one of four new files depending on their location.

Useful functions will be [php_man]fread[/php_man]() and [php_man]fwrite[/php_man]().
fastfingertips
Forum Contributor
Posts: 242
Joined: Sun Dec 28, 2003 1:40 am
Contact:

Post by fastfingertips »

Also a fast way is to save your excel file into a csv format then use the "fgetcsv" function.

All this because Excel files are binary and cannot be read by PHP.

The only way to do this would be to have Excel installed on a windows server which is running PHP and then convert the file using COM functions. This solution will only work on a server running Windows.

Hm also there is another possibility: ODBC :P
S_henry
Forum Contributor
Posts: 148
Joined: Sun Jan 25, 2004 10:25 pm
Location: M'sia

Post by S_henry »

Thanx for the responses. I will try to find out first and come back here again if get any problem. Thanx..
User avatar
JayBird
Admin
Posts: 4524
Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:

Post by JayBird »

You can read Excel files, but the script ain't free

http://www.zakkis.ca/products/index.php?s=6&p=37
Do you need a script that can read MS Excel files and save the data in
database, HTML pages and etc.? Do you want to do it with PHP under Unix and
Linux but without using Windows tools like COM? Then PHP - Excel file parser
is the right tool for you. All you will need is just our excelparser.php and
PHP enabled web server without any further tools.

The Professional version of PHP Excel Parser, has the debug function,
support multiple Excel font and formula processing! It also reads Excel
Dates prior 01.01.1970!

What's new in 4.0 version:
Support MAC Excel files
Mark
Post Reply