in reply to Re: Re: Using the mysql database columns as the table header.
in thread Using the mysql database columns as the table header.

The start_td command is just like the <TD> command in raw HTML:  it doesn't contain actual text, just property settings like "align=left."  So, your code should look like this for a table data cell:

print $query->start_th({-width=>'150', -align=>'center', -colspan=>'2'}), "COACHING STAFF","\n", $query->end_th;

Of course, I'm not an expert at the CGI.pm and could very well be wrong about including text in the start_th.  But if you include the text in the directive, you may get yourself into the situation you were in before of directives getting intertwined with your while statement.  In short, I'm not giving you advanced advice here, but simple and managable ideas for keeping your sanity.  So, feel free to ignore me, as others will probably trump my post.

That's Spenser, with an "s" like the detective.

Replies are listed 'Best First'.
Re: Re: Re: Re: Using the mysql database columns as the table header.
by mnlight (Scribe) on Dec 28, 2001 at 09:55 UTC
    Why does this code not print the links below the table?
    print $query->table({-ALIGN=>'CENTER', BORDER=>''}, Tr({-bgcolor=>'#9933FF', -valign=>'TOP'}, [ th({-width=>'20%', -align=>'center'}, 'PLAYER NAME').th({-widt +h=>'30%', -align=>'center'}, 'ADDRESS').th({-width=>'20%', -al ign=>'center'}, 'PHONE NUMBER').th({-width=>'200', -align=>'center'}, +'FATHER').th({-width=>'200', -align=>'center'}, 'MOTHER').th({ -width=>'100', -align=>'center'}, 'DATE OF BIRTH').th({-width=>'100', +-align=>'center'}, 'ASSOCIATION').th({-width=>'50', -align=>'c enter'}, 'NUMBER').th({-width=>'50', -align=>'center'}, 'POSITION').th +({-width=>'25', -align=>'center'}, 'SHOOTS'), ] ) ); while (my @val = $sth->fetchrow_array ()) { print $query->table({-ALIGN=>'CENTER', BORDER=>''}, Tr({-bgcolor=>'#99FF99', -valign=>'TOP'}, [ td({-width=>'20%', -align=>'center'}, $val[0]).td({-width=>'30 +%', -align=>'center'}, $val[1]).td({-width=>'20%', -align=>'ce nter'}, $val[2]).td({-width=>'200', -align=>'center'}, $val[3]).td({-w +idth=>'200', -align=>'center'}, $val[4]).td({-width=>'100', -a lign=>'center'}, $val[5]).td({-width=>'100', -align=>'center'}, $val[6 +]).td({-width=>'50', -align=>'center'}, $val[7]).td({-width=>' 50', -align=>'center'}, $val[8]).td({-width=>'25', -align=>'center'}, +$val[9]), ] ) ); print $query->end_html(); } $query->start_table({-ALIGN=>'CENTER',}), $query->start_Tr({-bgcolor=>'#9933FF', -valign=>'TOP', -align= +>'center'}), $query->start_th({-align=>'center',}), "PLAYER NAME", $query->start_th({-align=>'center',}), "ADDRESS", $query->start_th({-align=>'center',}), "PHONE NUMBER", $query->start_th({-align=>'center',}), "FATHER", $query->start_th({-align=>'center',}), "MOTHER", $query->start_th({-align=>'center',}), "BIRTH-DATE", $query->start_th({-align=>'center',}), "ASSOCIATION", $query->start_th({-align=>'center',}), "NUMBER", $query->start_th({-align=>'center',}), "POSITION", $query->start_th({-align=>'center',}), "SHOOTS", $query->end_th, $query->end_Tr; while (my @val = $sth->fetchrow_array ()) { print $query->start_Tr({-bgcolor=>'#99FF99', -valign=>'TOP', -align= +>'center'}), $query->start_td({-align=>'center',}), $val[0], $query->start_td({-align=>'center',}), $val[1], $query->start_td({-align=>'center',}), $val[2], $query->start_td({-align=>'center',}), $val[3], $query->start_td({-align=>'center',}), $val[4], $query->start_td({-align=>'center',}), $val[5], $query->start_td({-align=>'center',}), $val[6], $query->start_td({-align=>'center',}), $val[7], $query->start_td({-align=>'center',}), $val[8], $query->start_td({-align=>'center',}), $val[9], $query->end_Tr; } $query->end_table, $query->a({-href=>'Roster.pl'}, h2('ROSTER'),), print $query->end_html;

      Try enclosing your variables within double-quotes:

      $query->start_td({-align=>'center',}), "$val[0]",

      That's Spenser, with an "s" like the detective.