function show_table($count ,$limit)
{
global $connection;
for($i = 0; $i < $limit; $i++)
{
$str .= "<tr>";
for($j = 1; $j <= $count; $j++)
{
$sql = "select * from table_b where pid = $j limit $i,1";
$result = exequery($connection,$sql);
$row = mysql_fetch_array($result);
$str .= "<td style='border:1px solid red'>".$row['name']."</td>";
}
$str .= "</tr>";
}
return $str;
}
$str = "<table style=\"border: solid 1px #ff0000;\" >";
$sql = "select count(*) from table_b where pid = '0'";
$result = exequery($connection,$sql);
$row = mysql_fetch_array($result);
$count = $row[0];
$sql = "select * from table_b where pid = 0";
$result = exequery($connection,$sql);
$str .= "<tr>";
while($row = mysql_fetch_array($result))
{
$str .= "<td style='border:1px solid red'>".$row['name']."</td>";
}
$str .= "</tr>";
$str .= show_table($count,3);
$str .= "</table>";
echo $str;
效果图:
可以注释一下代码,然后再重点介绍一下思路吗?!