獲得精確值不是Select specific value from a fetched array從獲取陣列從MySQL
,這裏是我的查詢:
$sql = "SELECT * FROM data ORDER BY Score DESC";
我希望它是一個人們可以更新其得分的排行榜,所以我不能使用
$sql = "SELECT * FROM data ORDER BY Score DESC WHERE ID = 1";
我想在第二行的用戶名在我query.So我寫道:
<?php
include "l_connection.php";
$sql = "SELECT * FROM data ORDER BY Score";
$result = mysqli_query($conn, $sql);
if($result->num_rows>0){
while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)){
}
echo "Result = '".$row[1]['Username']."''";
}
?>
但它返回的結果=「」好像有什麼在數組中。
但如果我寫
if($result->num_rows>0){
while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)){
echo "Name = '".$row['Username']."''";
}
}
這將返回:帕勒姆,Mojtaba,Gomnam,馬蘇德, 那我在第一個片段做錯了什麼?