我有數據具有完整的數據集...SORT在mysql_fetch_array一個特定的值
Id | loc |SubLoc |beds
1 15 5803 1
2 15 5803 1
3 16 2813 1
4 16 2813 2
5 16 2830 1
6 20 2020 4
7 19 2513 3
我有這個PHP/MySQL的代碼來遍歷它
select id,loc,SubLoc,beds from table where id != 144 AND price > 140000 AND price < 210000 AND category_id=1
while($rw = mysql_fetch_array($rs2)){}
現在我想排序$ RW以這種方式
我有三個值
loc=16,SubLoc=2813,beds=1
我想顯示同樣的結果,但顯示出以這種方式
1- having loc==16 on top then
2- having SubLoc = 2813 then
3- having beds = 1
所有結果,然後結果
這如何可以在PHP中做的休息嗎?
修訂
我想這些ID
3 as it matches 3 parameters
4 as it matches 2 parameters
5 as it matches 2 parametrs
1 as it matches 1 parameter
等
爲什麼不在mysql中排序呢? –
你的查詢是什麼? –