- 论坛徽章:
- 0
|
<?php
/*
select返回的值为$r
第1列值one,第2列值tow
*/
$r=array(
0=>array(
"one" => "asd",
"tow" => 111
),
1=>array(
"one" => "cay",
"tow" => 321
),
2=>array(
"one" => "cay",
"tow" => 1321
),
3=>array(
"one" => "asd",
"tow" => 1321
),
4=>array(
"one" => "cay",
"tow" => 1221
)
);
for($i = 0;$i<count($r);$i++){
$new_r["one"][$i] = $r[$i]["one"];
}
sort($new_r["one"]);
$count = array_count_values($new_r["one"]);
$temp="";
$html ="<table border=\"1\" bordercolor=\"#000000\" >\r\n";
foreach($new_r["one"] as $k => $v){
if($v == $temp){
$html.= "<tr><td>". $r[$k]["tow"]."</td></tr>\r\n";
}else{
$html.= "<tr><td rowspan=\"".$count[$v]."\">".$v."</td><td>". $r[$k]["tow"]."</td></tr>\r\n";
}
$temp = $v;
}
$html .="</table>\r\n";
echo $html;
?> |
很实际的人呢~~我可以带写,但收费,有意联系 |
|