php动态生成表格的合并
2009-12-02 09:43
459 查看
<?php
$link=mysql_connect("localhost","root","root");
$db=mysql_select_db("bustest",$link);
$sql1="select name from info group by name order by id asc";
print("<table border='1'>");
$res1=mysql_query($sql1);
while($row1=mysql_fetch_array($res1)){
$name=$row1["name"];
$sql2="select id from info where name ='$name' order by id asc";
$res2=mysql_query($sql2);
while($row2=mysql_fetch_array($res2)){
print("<tr>");
$id=$row2["id"];
print("<td>$id</td>");
$sql3="select count(*),id from info where name ='$name' group by name order by id asc";
$res3=mysql_query($sql3);
while($row3=mysql_fetch_array($res3)){
$id1=$row3["id"];
if($id1==$id){
$num=$row3[0];
print("<td rowspan='$num' >");
print $name;
print("</td>");
}else{
print("</tr>");
}
}
}
print("</tr>");
}
print("</table>");
mysql_close($link);
?>
$link=mysql_connect("localhost","root","root");
$db=mysql_select_db("bustest",$link);
$sql1="select name from info group by name order by id asc";
print("<table border='1'>");
$res1=mysql_query($sql1);
while($row1=mysql_fetch_array($res1)){
$name=$row1["name"];
$sql2="select id from info where name ='$name' order by id asc";
$res2=mysql_query($sql2);
while($row2=mysql_fetch_array($res2)){
print("<tr>");
$id=$row2["id"];
print("<td>$id</td>");
$sql3="select count(*),id from info where name ='$name' group by name order by id asc";
$res3=mysql_query($sql3);
while($row3=mysql_fetch_array($res3)){
$id1=$row3["id"];
if($id1==$id){
$num=$row3[0];
print("<td rowspan='$num' >");
print $name;
print("</td>");
}else{
print("</tr>");
}
}
}
print("</tr>");
}
print("</table>");
mysql_close($link);
?>
相关文章推荐
- php动态生成表格的合并
- PHP——动态生成mysql表格
- PHP--动态生成sql查询表格
- java动态生成pdf含表格table和 合并两个pdf文件功能
- (转载)PHP 动态生成表格
- phpexcel 生成表格
- ASP.net中动态生成表格/文本框以及获取文本框内容的方法
- poi根据模板导出word(包含图片、动态生成表格、合并单元格)
- asp.net 生成word 动态的填充表格(Microsoft的自带组件)
- 动态生成适用于像sql的where条件拼接的面板js代码 与 php处理代码 (二)
- jquery 动态表格合并
- 动态生成表格制作
- Javascript中给动态生成的表格添加样式,JavaScript里setAttribute的问题
- php动态生成JavaScript代码
- JS动态生成表格后 合并单元格
- javascript动态生成表格,可传值
- php生成动态验证码gif图片
- android动态生成表格,使用的是TABLELAYOUT
- JS动态生成表格
- 在.net中利用Web控件Table动态生成表格