issue with dynamically setting table header

Thomas Nyman <[email protected]>
Newsgroups gmane.comp.lang.perl.modules.html-template
Message-ID <[email protected]>
Hi

I query mysql using fetchall_arrayref({}).

I the dereference the AoH and delete any empty key->values.

After that i wish to output the  AoH to the template. However has  
things stand now there are empty table headers.

An illustrative example

The query gets this result

+-----------+-----------------------------+------------------- 
+------------+-----------------+-------------------+------------- 
+--------------------------------+
| Klient_ID | Namn                            |  
Pnr                    | Ort        | Telefon         |  
Telefax               | Mobil       | Epost                          |
+-----------+-----------------------------+------------------- 
+------------+-----------------+-------------------+------------- 
+--------------------------------+
|       990 | AbbbCCCC                 | 1234567778 | Umeå       |  
090-111111   |                         |                          |  
[email protected] |
|       991 | DDDDEEEE                | 8522240000 |  Umeå    
|                             |                        
|                         |                                |
|       992 | FFFFFGGGG            | 8234538525 | Umeå       |  
090-333333|                             |                          
|                                |
|       993 | HHHHIIIIII                 | 8134878510 | UMEÅ       |  
090-222222      |                        |                          
|                                |
|       994 | JJJJJKKKKK             | 5810124598 | Lycksele   
|                             |                         
|                         |                                |
+-----------+-----------------------------+------------+------------ 
+-----------------+------------+------------- 
+--------------------------------+

As we can se the fields Klient_ID, Namn, Pnr, Ort, Telefon, Epost  
have at least one value in one row. The fields Mobil and Telefax have  
no values.
When i dreference I delete all key->value pairs where there is no value.

In my template I have the following
<th>Klient_ID</th>
<th>Namn</th>
etc for all the field names.

This has the effect that I have empty tableheaders , for instance  
Telefax is completely empty and should not be displayed.

To fix this I would like to set the <th>value</th> dynamically frpm  
my perlscript.

Since I cannot know beforehand how many, if any, columns will be  
empty I need som way to check for empty fields. I can get it to work  
if my query only gets one hit, but I have been unable to do so if the  
query generates more than one hit (i.e more than one row).

I'm beginning to think that I am missing something fundamental -  
something that perhaps seems simple -  but at the moment I am at my  
wits end.

I would greatly appreciate it if someone could give me an idea of  
what to do.

Thomas



-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO
September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.