PHP头条
热点:

PHP生成表格实例代码


下面代码PHP生成表格实例,经过本站编程之家测试正常运行后贴出来的。

  1. <?php
  2. $link=mysql_connect("localhost","root","123456");
  3. $db=mysql_select_db("bustest",$link);
  4. $sql1="select name from info group by name order by id asc";
  5. print("<table border=1>");
  6. $res1=mysql_query($sql1);
  7. while($row1=mysql_fetch_array($res1)){
  8.     $name=$row1["name"];
  9.     $sql2="select id from info where name =$name order by id asc";
  10.     $res2=mysql_query($sql2);
  11.     while($row2=mysql_fetch_array($res2)){
  12.         print("<tr>");
  13.         $id=$row2["id"];
  14.         print("<td>$id</td>");
  15.         $sql3="select count(*),id  from info where name =$name  group by name  order by id asc";
  16.         $res3=mysql_query($sql3);
  17.         while($row3=mysql_fetch_array($res3)){
  18.             $id1=$row3["id"];
  19.             if($id1==$id){
  20.                 $num=$row3[0];
  21.                 print("<td rowspan=$num >");
  22.                 print $name;
  23.                 print("</td>");
  24.             }else{
  25.                 print("</tr>");
  26.             }
  27.         }
  28.     }
  29.     print("</tr>");
  30. }
  31. print("</table>");
  32. mysql_close($link);
  33. ?>   

www.phpzy.comtrue/phprm/24673.htmlTechArticlePHP生成表格实例代码 下面代码PHP生成表格实例,经过本站编程之家测试正常运行后贴出来的。 ?php $link=mysql_connect("localhost","root","123456"); $db=mysql_select_db("bustest",$link); $sql1="select name fro...

相关文章

    暂无相关文章

PHP之友评论

今天推荐