$res =mysql_query(select 工程,编码,sum(费用) from table group by 编码) foreach($res as $k=>$v){ $res[$k]['child'] = mysql_query(select 工程,编码,费用 from table where 编码=$v['编码']); } echo '<table><tr><td>工程</td><td>编码</td><td>费用</td></tr>'; foreach($res as $v){ echo '<tr><td>$v['工程']</td><td>$v['编码']</td><td>$v['费用']</td></tr>'; foreach($v['child'] as $vv){ echo '<tr style='display:none;'><td>$vv['工程']</td><td>$vv['编码']</td><td>$vv['费用']</td></tr>'; } } echo '</table>';
$res =mysql_query(select 工程,编码,sum(费用) from table group by 编码)
foreach($res as $k=>$v){
$res[$k]['child'] = mysql_query(select 工程,编码,费用 from table where 编码=$v['编码']);
}
echo '<table><tr><td>工程</td><td>编码</td><td>费用</td></tr>';
foreach($res as $v){
echo '<tr><td>$v['工程']</td><td>$v['编码']</td><td>$v['费用']</td></tr>';
foreach($v['child'] as $vv){
echo '<tr style='display:none;'><td>$vv['工程']</td><td>$vv['编码']</td><td>$vv['费用']</td></tr>';
}
}
echo '</table>';
初始时<tr>的style是'display:none;',点击时setAttribute为显示,但怎么获取setAttribute之后的属性值呢?我打算点击事件为:判断是none时就显示、判断是显示时就置none。