Copy codeThe Code is as follows:
<? Php
/*
* Author: xudafeng@126.com
* Blog: http://www.xdf.me
* Date: 2012.7.28
*/
Class danteng {
Function init ($ col1_name, $ col2_name, $ col3_name, $ time_unit ){
Echo "<table border = 1> <tr> <th> ". $ col1_name. "</th> <th> ". $ col2_name. "</th> <th colspan = \"". $ time_unit. "\"> ". $ col3_name. "</th> </tr> ";
}
Function baobiao_danteng ($ name, $ time_unit, $ pro_name, $ pre_name ){
Echo "<tr> <th rowspan = \"". count ($ pro_name ). "\"> $ name </th> <td> ". $ pro_name [0]. "</td> ";
For ($ I = 0; $ I <$ time_unit; $ I ++ ){
Echo "<td>". $ pre_name. $ I ."";
}
Echo "</tr> ";
For ($ j = 0; $ j <(count ($ pro_name)-1); $ j ++ ){
Echo "<tr> <td>". $ pro_name [($ j + 1)]. "</td> ";
For ($ I = 0; $ I <$ time_unit; $ I ++ ){
Echo "<td>". $ pre_name. $ I ."";
}
Echo "";
}
}
Function finish (){
Echo "";
}
}
?>
The call method is as follows:
Copy codeThe Code is as follows:
$ Init = new danteng ();
$ Init-> init ('type', 'project', 'unit of time ', $ time_num );
$ Init->; baobiao_danteng ('fuxi ', $ time_num, $ fuxi_pro, 'Pre _ n ');
$ Init->; baobiao_danteng ('nvwa ', $ time_num, $ nvwa_pro, 'unit ');
$ Init->; baobiao_danteng ('pangu ', $ time_num, $ pangu_pro, 'Ah ');
$ Init->; baobiao_danteng ('xiaoye', $ time_num, $ pangu_pro, 'egi ');
$ Init->; finish ();