Php dynamic implementation of table cross-row and cross-column implementation code _ php Basics-php Manual

Source: Internet
Author: User
Tags php basics
Due to the need to extract the report data generated by multiple servers according to the conditions, we may use php to dynamically generate a table that supports cross-row and cross-column data. it is often difficult to control table cross-row and cross-column data, in addition, the logic coupling of the row and column merging attributes is very high, so the following things are required for this time: The 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"










";}Function baobiao_danteng ($ name, $ time_unit, $ pro_name, $ pre_name ){Echo" ";For ($ I = 0; $ I <$ time_unit; $ I ++ ){Echo" ";For ($ j = 0; $ j <(count ($ pro_name)-1); $ j ++ ){Echo" ";For ($ I = 0; $ I <$ time_unit; $ I ++ ){Echo"
". $ Col1_name ." ". $ Col2_name ." ". $ Col3_name ."
$ Name ". $ Pro_name [0]."". $ Pre_name. $ I ."";
}
Echo"
". $ Pro_name [($ j + 1)]."". $ Pre_name. $ I ."";
}
Echo "";
}
}
Function finish (){
Echo "";
}
}
?>


The call method is as follows:

The 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 ();

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.