Hi all,
I want to make some of the results to list in a "group" way. For example, if the id: 1,2,3 and 4 are all having the same value in the number column, they will be grouped in a table, and so on. Now as i am a beginner to mysql & php, i can only make the results grouped in a large table, like this: http://www.dennistang.com/bus/jumbo/lf/
Could anyone please tell me how to do it?Thanks very much!
Attached with the code of that page for ref.:
$sql = "SELECT * FROM businfo limit 60,10;";
$sql_result = mysql_query($sql, $link) or die("Cannot connect to database. Error: ".mysql_error());
function ShowCell($p1) {
global $optionsstyle;
print "<td><strong><font color=\"#9966FF\"> $p1 </font></strong></td>";
}
function ShowCell1 ($p1) {
print "<td><font size=\"2\"> $p1 </font></td>";
}
function ShowCell2 ($p1) {
print "<td><font size=\"2\"> $p1 k</font></td>";
}
function ShowCell3 ($p1) {
print "<td width=\"90\"><font size=\"2\"> $p1 </font></td>";
}
echo "<table width=\"943\" border=\"1\" align=\"center\" cellpadding=\"0\" cellspacing=\"1\" style=\"$optionsstyle\">";
echo "<tr align=\"center\" bgcolor=\"#B9DAF5\"> ";
ShowCell("id");
ShowCell("Busnumber");
ShowCell("Busnumber2");
ShowCell("Photo Date");
ShowCell("Chinese Description");
ShowCell("English Description");
ShowCell("Filesize");
ShowCell("Route");
ShowCell("Regnumber");
ShowCell("Ad");
ShowCell("Photo");
print "</tr>";
while($row=mysql_fetch_object($sql_result)) {
print "<tr align=\"center\">";
ShowCell1("$row->id");
ShowCell1("$row->type $row->number");
if ($row->number2=="0") {ShowCell1(" ");}
else {ShowCell1("$row->type $row->number2");};
ShowCell1($row->photodate);
ShowCell1($row->cdescription);
ShowCell1($row->edescription);
ShowCell2("$row->filesize");
ShowCell1($row->route);
ShowCell1($row->regnumber);
ShowCell1($row->ad);
ShowCell1("<a href=\"javascript:popUp('photo.php?id=$row->id')\"><img src=$row->previewpath$row->previewfilename border=\"0\"></a>");
print "</tr>";
}
echo "</TABLE>";