Page headings and subheadings Image 请帮我,我想在上面的图片中显示表格 我必须从数据库和显示中获取表格标题 这里的子列将是无限的。
请在下面找到我的代码
$html ='<table border="1">';
$dhcollevel = "SELECT MAX(column_level) as maxcollevel FROM act_format_heading where act_format_id='".FORMATID."' and act_format_col_type ='DH' ";
$dhcollevelresult = mysqli_query($conn,$dhcollevel);
$dhcollevelresultrow = mysqli_fetch_array($dhcollevelresult);
if(!empty($dhcollevelresultrow)){
$maxcollevel = $dhcollevelresultrow['maxcollevel'];
}
for($col = 1; $col<= $maxcollevel;$col++){
$html .='<tr>';
$DHdatahead = "SELECT * FROM act_format_heading where act_format_id='".FORMATID."' and act_format_col_type ='DH' and column_level = '".$col."' order by column_level ASC,act_format_seq_no ASC";
$DHdataresult = mysqli_query($conn,$DHdatahead);
while ($row = mysqli_fetch_array($DHdataresult)){
$dhcolcontentdb = $row['act_format_content'];
$html .="<th><tr>".$dhcolcontentdb."</tr>";
if($row['has_sub_column'] == 1){
$html .="<tr>";
$DHdatasubhead = "SELECT * FROM act_format_heading where act_format_id='".FORMATID."' and act_format_col_type ='DH' and parent_id='".$row['act_format_id']."' order by column_level ASC,act_format_seq_no ASC";
$DHsubdataresult = mysqli_query($conn,$DHdatasubhead);
while ($row = mysqli_fetch_array($DHsubdataresult)){
$dhsucolcontentdb = $row['act_format_content'];
$html .="<td>".$dhsucolcontentdb."</td>";
}
$html .= "</tr>";
}
$html .= "</th>";
}
$html .='</tr>';
}
$html .='</table>';
请在下面找到我的sql表
CREATE TABLE `act_format_heading` (
`act_format_heading_id` int(11) NOT NULL,
`act_format_id` int(11) NOT NULL,
`act_id` int(11) NOT NULL,
`act_format_col_type` varchar(100) NOT NULL COMMENT 'PH,RH,DH',
`act_format_seq_no` int(11) NOT NULL,
`act_format_content` varchar(500) NOT NULL,
`act_format_input_type` varchar(100) NOT NULL,
`act_format_input_type_col_name` varchar(200) NOT NULL,
`act_format_content_align` varchar(100) NOT NULL,
`act_format_content_width` int(11) NOT NULL,
`parent_id` int(11) NOT NULL,
`column_level` int(11) NOT NULL COMMENT 'if 0- PH and RH, else DH',
`has_sub_column` tinyint(4) NOT NULL COMMENT 'Belongs to DH',
`created_by` int(11) NOT NULL,
`updated_by` int(11) NOT NULL,
`created_datetime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`updated_datetime` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00'
);
INSERT INTO `act_format_heading` (`act_format_heading_id`, `act_format_id`, `act_id`, `act_format_col_type`, `act_format_seq_no`, `act_format_content`, `act_format_input_type`, `act_format_input_type_col_name`, `act_format_content_align`, `act_format_content_width`, `parent_id`, `column_level`, `has_sub_column`, `created_by`, `updated_by`, `created_datetime`, `updated_datetime`) VALUES
(1, 216, 102, 'DH', 1, 'H1', 'S1', 'col0', 'center', 50, 0, 1, 0, 1, 0, '2016-10-21 12:46:43', '0000-00-00 00:00:00'),
(2, 216, 102, 'DH', 2, 'H2', 'S1', 'col1', 'center', 50, 0, 1, 0, 1, 0, '2016-10-21 12:46:43', '0000-00-00 00:00:00'),
(3, 216, 102, 'DH', 3, 'H3', '', '', 'center', 50, 0, 1, 1, 1, 0, '2016-10-21 12:46:43', '0000-00-00 00:00:00'),
(4, 216, 102, 'DH', 1, 'H3-1', 'S1', 'col2', 'center', 50, 3, 2, 0, 1, 0, '2016-10-21 12:46:43', '0000-00-00 00:00:00'),
(5, 216, 102, 'DH', 2, 'H3-2', '', '', 'center', 50, 0, 1, 3, 2, 1, '2016-10-21 12:46:43', '0000-00-00 00:00:00'),
(6, 216, 102, 'DH', 3, 'H3-3', 'S1', 'col3', 'center', 50, 3, 2, 0, 1, 0, '2016-10-21 12:46:43', '0000-00-00 00:00:00'),
(7, 216, 102, 'DH', 1, 'H3-2-1', 'S1', 'col4', 'center', 50, 5, 3, 0, 1, 0, '2016-10-21 12:46:43', '0000-00-00 00:00:00'),
(7, 216, 102, 'DH', 2, 'H3-2-2', 'S1', 'col5', 'center', 50, 5, 3, 0, 1, 0, '2016-10-21 12:46:43', '0000-00-00 00:00:00'),
(8, 216, 102, 'DH', 4, 'H4', 'S1', 'col6', 'center', 50, 0, 1, 0, 1, 0, '2016-10-21 12:46:43', '0000-00-00 00:00:00');