i have a certain code i been using to draw my tables, but now after a while I am wondering if there is a way to set the width of the columns using the code i have or if i need to
rework what i have done.
here is my code and i have put some text in red to help out hopefully
[COLOR="#FF0000"]This bit here gathers the info to be displayed[/COLOR]
$injuries .= draw_table(array(
'title' => $row['name'],
'title_color' => '#FFFFFF',
'headers' => array('Player','Date','Status','Injury'), [COLOR="#FF0000"]This is what i want to set the column width on[/COLOR]
'fields' => $fields,
'bgtitle' => '#484F53',
'footer' => array(array('No Current Injuries')),
'footer_span' => '4',
'bgheaders' => '#BD2414',
'bgcolors' => array('#EFEFEF', '#DFDFDF')
));
}
mysql_free_result($result);
$contents = eregi_replace("<!--%LEAGUE_TITLE%-->", $league_name, $contents);
$contents = eregi_replace("<!--%INFO%-->", $injuries, $contents);
return $contents;
}
[COLOR="#FF0000"]This displays the stuff from what we gathered from above[/COLOR]
function draw_table($o){
$result = '<table bgcolor="'.$o['bgtitle'].'" width="100%" border="0" cellspacing="0" cellpadding="0" align="center">'.
'<tr>'.
' <td bgcolor="#FFFFFF">'.
' <table border="0" width="100%" cellpadding="2" bordercolor="'.$o['bgtitle'].'" cellspacing="1">'.
' <tr align="center" bgcolor="#efefef">'.
' <td bgcolor="'.$o['bgtitle'].'" colspan="'.count((isset($o['headers']) ? $o['headers'] : $o['fields'][0])).'" class="table_header" align="left"><font color="'.(isset($o['title_color']) ? $o['title_color'] : '#000000').'">'.$o['title'].'</font></td>'.
' </tr>';
if ($o['headers']){
$result .= '<tr bgcolor="'.$o['bgheaders'].'" align="center" >';
foreach($o['headers'] as $h){
$result .= '<td class="table_header" width="$o['headers_width']">'.$h.'</td>';
}
$result .= '</tr>';
}
if ($o['fields']){
$i = 0;
foreach($o['fields'] as $f){
$result .= '<tr bgcolor="'.($i%2 == 0 ? $o['bgcolors'][0] : $o['bgcolors'][1]).'" align="left">';
foreach($f as $v){
$result .= '<td class="table_text" '.(count($f) == 1 ? 'colspan="'.count((isset($o['headers']) ? $o['headers'] : $o['fields'][0])).'"' : '').'>'.($v != '' ? $v : '0').'</td>';
}
$result .= '</tr>';
$i++;
}
}
if ($o['footer'] && !$o['fields']){
$fi = 0;
foreach($o['footer'] as $f){
$first_time = 1;
$result .= '<tr bgcolor="'.($o['footer_color'] ? (is_string($o['footer_color']) ? $o['footer_color'] : $o['footer_color'][$fi]) : $o['bgtitle']).'" align="center">';
foreach($f as $v){
$result .= '<td '.($first_time ? 'colspan="'.(is_string($o['footer_span']) ? $o['footer_span'] : $o['footer_span'][$fi]).'"' : '').' class="table_text"><b><font color="'.(isset($o['title_color']) && $fi == 0 ? $o['title_color'] : '#000000').'">'.($v != '' ? $v : '0').'</font></b></td>';
$first_time = 0;
}
$result .= '</tr>';
$fi++;
}
}
return $result.'</table></td></tr></table><br />';
}