对于我的第一个php工作,可以输入和显示可用住房的地址和描述。现在尝试按住房类别类型进行细分/展示,即房屋、公寓、复式公寓、公寓。所有信息都在同一张表中。我有一个名为Category的行,对应的值为1、2、3、4,我希望将其用作类别类型。我正在努力与手册,并将感谢任何指导。非常感谢您的时间和帮助。
以下是我当前用于显示整个列表的内容。
while($res=mysql_fetch_array($result))
{
echo "<tr>";
echo "<td valign='"top'" class='address' width='"180'" colspan='"3'">".$res['address']."</td>";
echo "</tr>";
echo "<tr>";
echo "<td valign='"top'" class='text_box' width='"420'" colspan='"3'">".$res['desc1']."</td>";
echo "</tr>";
echo "<tr>";
echo "<td valign='"top'" align='"left'" class='text_box' width='"100'">".$res['bds']."</td>";
echo "<td valign='"top'" align='"left'" class='text_box' width='"100'">".$res['bath']."</td>";
echo "<td valign='"top'" align='"left'" class='text_box' width='"412'"></td>";
echo "</tr>";
}
echo "</table>";
不确定我是否正确理解了这个问题,但在进行MySQL调用时,是否不可能按类别对行进行排序?'按类别排序'或您的列名。
http://www.sql-tutorial.com/sql-order-by-sql-tutorial/