2017-07-04 74 views
-1

我需要一個幫助。我從表中以降序獲取數據。在這裏,我需要使用PHP和MySQL在特定位置獲取一條記錄。我在下面解釋我的表格。如何使用PHP和MySQL將特定數據保存在數組中的特定位置

db_special:

id  special_name    type 

1  F & B     1 

2  Liquor     2 

3  Entertainment   3 

在這裏我得到的數據如下圖所示。

$sql=mysqli_query($connect,"select * from db_special order by id desc"); 
while($row=mysqli_fetch_array($sql)){ 
    $data[]=$row; 
} 

print_r($data); 

在這裏,我需要保持Liquor應該來F & B and Entertainment但在我的情況下,在第二位置,它的到來。請幫幫我。

+0

酒應該是第一位的? –

+1

餐飲和娛樂之後,總會有酒味來臨。 – subhra

+0

select * from db_special order by special_name .try這個 –

回答

0

然後你應該按ASC排序(升序)。降序意味着從最大數量開始下降。

0

如果你要像F&BEntertainmentLiquor數據順序,然後

試試這個

$sql=mysqli_query($connect,"select * from db_special ORDER BY `special_name` ASC"); 
相關問題