[thelist] PHP & Crosstabs [long]

rudy r937 at interlog.com
Tue May 7 13:35:52 CDT 2002

> SELECT RecordDate
>   SUM(IF(RecordID = '100101', 1, 0)) AS r100101,
>   SUM(IF(RecordID = '100118', 1, 0)) AS r100118,
>   SUM(IF(RecordID = '100119', 1, 0)) AS r100119,
>   SUM(IF(RecordID = '100120', 1, 0)) AS r100120
>  FROM tblCrosstab
> GROUP BY RecordDate
>...so far, so good.

hi jay

missing a comma after RecordDate, but don't stick it in just yet...

you have a messy php if statement there, which appears to check to see
whether the record is the last in the series, and if so, don't include the
trailing comma

well, you can simplify the code and avoid the if statement if you simply
put the comma in front of each term -- and don't put one after RecordDate!

> Here is the problem...I need to create a table row for
> each RecordDate. [snip]
> Of course the query does exactly this in DB,
> I just have to do it with PHP and HTML where I do not know
> how many rows (RecordDates) there might be.

um, i don't get it, maybe i'm missing something

why not just run that query?  why do you need to know how many?

the first query will tell you which RecordIDs you have, and that helps
construct the TH row

after that, just loop through the results, building TD rows as you go



More information about the thelist mailing list