- 论坛徽章:
- 12
|
自己写的一段代码
$sql1="select count(*),ip from nagios_ip_tmp group by ip order by ip";
$result1 = mysql_query($sql1);
echo "<table border='1' cellspacing='0' cellpadding='0' align='left'>
<tr>
<th>ip</th>
<th>check_type</th>
<th>count</th>
</tr>";
while($row = mysql_fetch_array($result1))
{
$ip=$row['ip'];
$num=$row[0];
echo "<tr>";
echo "<td rowspan='$num'>" . $row['ip'] . "</td>";
$sql2="select check_type,count from nagios_ip_tmp where ip='$ip'";
$result2= mysql_query($sql2);
$i=1;
while($row2 = mysql_fetch_array($result2))
{
if($i==1){
echo "<td>" . $row2['check_type'] . "</td>";
echo "<td>" . $row2['count'] . "</td>";
echo "</tr>";
}else{
echo "</tr>";
echo "<td>" . $row2['check_type'] . "</td>";
echo "<td>" . $row2['count'] . "</td>";
echo "</tr>";
}
$i=$i+1;
}
}
echo "</table>";
|
|