2014-03-27 50 views
0

我有5個sp_id,$ count也給了5個。但是當我通過mysqli_fetch_array檢查大小時,它給了我2號尺寸,只打印1並給出錯誤未定義偏移量:1進一步。獲取ids的值,我的意思是通過for循環打印id。mysqli_fetch_array錯誤未定義的偏移量:1

 $selectId="Select sp_id from stitchedproduct"; 
$selectIdR = mysqli_query($connection,$selectId) or die(mysqli_error($connection)); 
$count = mysqli_num_rows($selectIdR); 
$fetchedResult= mysqli_fetch_array($selectIdR); 

for ($i=0;$i < $count; $i++) { 
print $fetchedResult[$i]; 
    } 
+0

嘗試的print_r($ fetchedResult); –

+0

它沒有工作:( –

回答

0

更換

$fetchedResult= mysqli_fetch_array($selectIdR); 

for ($i=0;$i < $count; $i++) { 
    print $fetchedResult[$i]; 
} 

while($fetchedResult= mysqli_fetch_array($selectIdR)) { 
    print $fetchedResult['sp_id']; 
} 
+0

沒有它沒有工作仍然未定義偏移錯誤:( –

+0

感謝while循環已經工作:) :) –

+0

@SylviaGerald沒有upvote和答案接受?:) – rakeshjain