[prog] mysql, php, arrays

Conor Daly c.daly at met.ie
Fri Oct 24 11:51:05 EST 2003


On Tue, Oct 14, 2003 at 09:15:17PM -0400 or thereabouts, wolf wrote:
> what is a pivat table and what program is needed?  it just happens this 
> student was in attendance
> for all days, status can also report back absent or late.

A pivot (note spelling, my fault, I spelled it wrongly in the first place)
table is the result of comparing some property of a pair of columns of data.
For example, you have a lecture timetable in a list thus:

Subject		Day	Time	Room
Math		Monday	0900	12
DBMS		Monday	1000	7
Hardware	Monday	1100	13
DBMS		Tuesday	1300	7
Comms		Tuesday	1500	Lab1
Lab		Thurs	1300	Lab2
Lab		Thurs	1400	Lab2
Lab		Thurs	1500	Lab2
Math		Friday	1200	3

Hardware	Monday	1000	7

not so easy to check as you dash down the corridor.  If you create a pivot
table of Subject on Day and Time, you get:

	0900	1000	1100	1200	1300	1400	1500
Mon	Math	DBMS	Hardware
Tue					DBMS		COMMS
Wed
Thu					Lab	Lab	Lab
Fri				Math

And a pivot table of frequency of time and room gets you:

Monday	0900	1000	1100	1200	1300	1400	1500
1
2
3				
7		2
12	1
13	1
Lab1
Lab2

Which shows you that you have accidentally scheduled two different classes
to use room 7 at 1000 on Monday.

So, in your case, you have a list of student ID, day and count of attendance
thus:

Student		Day	In
801		Mon	2
801		Tue	1
801		Wed	2
801		Thu	2
822		Mon	2
822		Wed	2
822		Thu	2
822		Fri	2
:
:
:

A pivot table of attendance on Student, Day gives you:

	Mon	Tue	Wed	Thu	Fri
801	2	1	2	2
822	2		2	2	2
837	2	2	2	2	2
923	1	1	1	2	2

Now you see that student 801 skipped one Tuesday and has no classes on
Friday, 822 has nothing on a Tuesday, 837 missed nothing while 923 was out
sick for 3 days running.

Apologies for the delay in replying...

Conor
-- 
Conor Daly 
Met Eireann, Glasnevin Hill, Dublin 9, Ireland
Ph +353 1 8064276 Fax +353 1 8064247
------------------------------------
bofh.irmet.ie running RedHat Linux 11:32:48  up 50 days, 56 min, 17 users,  load average: 0.00, 0.00, 0.00



**********************************************************************
This e-mail and any files transmitted with it are confidential 
and intended solely for the addressee. If you have received
this email in error please notify the sender.
This e-mail message has also been scanned for the
presence of computer viruses.
**********************************************************************



More information about the Programming mailing list