PHP生成表格实例代码
来源:未知 责任编辑:智问网络 发表时间:2013-10-30 11:07 点击:次
	   
	
	  
	  
	  下面代码PHP生成表格实例,经过本站编程之家测试正常运行后贴出来的。
	
	- <?php
 - $link=mysql_connect("localhost","root","123456");
 - $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);
 - ?>
 
相关新闻>>
- 发表评论
 - 
				
 
- 最新评论 进入详细评论页>>
 





![smarty局部缓存技术[源码分析]](/uploads/allimg/130827/11214T939-0-lp.jpg)