PHP foreach problem.

Permabanned
Joined
25 Oct 2004
Posts
9,078
Hiya All,

Run into a problem on my site, ive got a table that lists all current voluntary groups registered with our site, the issue im having is with the table sorting/display itself.

The basic idea is that the table is generated dynamically with php, this all works as it should but because of how it was coded the header titles on the table are all lower case with underscores seperating each word kinda like "charity_name" which imho looks unprofessional.

I've looked in the php code and found that the buttons are generated using a foreach loop.

PHP:
    foreach ( $table_fields as $val)
            $out .= "<th style='text-align: center'><input type='button' onclick='gmod_sndReq(\"$val\")' value='$val1' /></th>\n";

I've attempted to modify the code so that it pulls the table headers from a different array, tried to use a foreach loop again but that just resulted in a messed up table with duplicate headers.

Could anyone suggest how i could implement code so that it pulls the headers from a different array while still keeping the $table_fields array intact for the java onclick script to function.

Thanks in advance.
 
you either do the table head outside the loop or maybe have an if statement inside it to determine if it's the first iteration, display the header, if not table content.... not sure i fully understand your post tbh.... :p
 
Back
Top Bottom