distID distName regID
1 Khulna 1
2 Shatkhira 1
3 Bagerhat 1
4 Pirojpur 1
5 Barishal 2
6 Barguna 2
7 Patuakhali 2
8 Bhola 2
9 Jhalokathi 2
您好我有上表,可以正常显示数据。我需要在输出中对 regID 字段进行分组。我怎样才能做到这一点?下面是我的php代码。
<?php
include("db.php");
$result=mysql_query("SELECT * from district d inner join region r on d.regID=r.regID");
// $result1=mysql_fetch_array(mysql_query("SELECT * FROM district"));
// echo '<pre>';
//print_r($result);
while($test = mysql_fetch_array($result))
{ //print_r($test);
$id = $test['distID'];
echo "<tr align='center'>";
echo"<td><font color='black'>" .$test['distName']."</font></td>";
echo"<td><font color='black'>" .$test['regName']."</font></td>";
echo"<td> <a href ='view.php?distID=$id'>Edit</a>";
echo"<td> <a href ='del.php?distID=$id'><center>Delete</center></a>";
echo "</tr>";
}
mysql_close($conn);
?>