LPM: "on break" processing in perl?
Joe Hourcle
oneiros at dcr.net
Thu Jan 25 08:53:45 CST 2001
On Mon, 22 Jan 2001, David Hempy wrote:
>
> I keep running into the situation where I am reading rows from a database,
> presenting the rows in groups and subgroups. For example:
>
> select coursenumber, sectionnumber, ssnum
> from studentview
>
> This might return:
>
> CS101, 1, 000-00-1111
> CS101, 1, 000-00-2222
> CS101, 1, 000-00-3333
> CS101, 2, 000-00-4444
> CS101, 2, 000-00-5555
> CS117, 1, 000-00-1111
> CS117, 1, 000-00-9999
>
>
> I would like to display something like:
>
> CS101: 7 students
> Section 1: 3 students
> 000-00-1111
> 000-00-2222
> 000-00-3333
> Section 2: 2 students
> 000-00-4444
> 000-00-5555
> CS117: 2 students
> Section 1: 2 students
> 000-00-1111
> 000-00-9999
>
>
> (Actually, I am usually plugging these into HTML tables, but the idea is
> the same.)
This is just the sort of thing that PHP and ColdFusion are for.
[Although it could be done in Perl, it never hurts to learn a few new
tricks].
I'm not familiar with all of the PHP syntax myself, but I know in
coldfusion you'd want:
<CFQUERY NAME="class_list" DBTYPE=ODBC DATASOURCE="cf_defined_datasource">
SELECT coursenumber,sectionnumber,ssnum
FROM studentview
ORDER BY coursenumber,sectionnumber,ssnum
</CFQUERY>
<CFOUTPUT QUERY="class_list" GROUP="coursenumber">
(coursenumber heading goes here)
<CFOUTPUT GROUP="sectionnumber">
(sectionnumber heading goes here)
<CFOUTPUT>
(each record to display)
</CFOUTPUT>
(sectionnumber footing)
</CFOUTPUT>
(coursenumber footing)
</CFOUTPUT>
I'm guessing it'd be something rather similar in PHP.
-----
Joe Hourcle
More information about the Lexington-pm
mailing list