Auto Column Widths using MySQL/PHP
Here's MySQL/PHP code that you can slot in right prior to echo activewidgets_grid($name, $data);
The only variable you should have to control is $data. $data should be the resulting recordset from mysql_query() command.
I have a $min_col_length variable that you can set, which will allow you to play with the widths a little more. It will prevent columns with very small data lengths from fouling up the headers, as well as giving the columns a much nicer flow.
The only variable you should have to control is $data. $data should be the resulting recordset from mysql_query() command.
I have a $min_col_length variable that you can set, which will allow you to play with the widths a little more. It will prevent columns with very small data lengths from fouling up the headers, as well as giving the columns a much nicer flow.
// dynamic column width
$records = mysql_numrows($data);
for($i=0; $i < $records; $i++) {
$row = mysql_fetch_row($data);
$length = mysql_fetch_lengths($data);
foreach($length as $key => $value) {if($maxlength[$key] < $value) {$maxlength[$key] = $value;} }
}
mysql_data_seek($data,0);
$min_col_length = 30;
print "<style>";
foreach($maxlength as $key => $value) {if($value * 10 < $min_col_length) {print".active-column-$key {width:" . ($min_col_length) . "px}";} else {print".active-column-$key {width:" . ($value * 10) . "px}";}}
print "</style>";
BMW
January 10,