while ($row = mysql_fetch_array($result)){
$xxx = $row[ ___ ]; //底線部份的陣列索引值可以是數字(即數字索引)或字串(即關聯索引)
}
但是,有時候也會看到mysql_fetch_array()被mysql_fetch_assoc()或mysql_fetch_row()代替,其實只有一點差別...
mysql_fetch_array()從資料集取得的陣列,索引值可以是數字(數字索引)或字串(關聯索引)。
$a=$row[0]; 或 $a=$row["a"];
mysql_fetch_assoc()從資料集取得的陣列,索引值只能是字串(關聯索引)。
$a=$row["a"];
mysql_fetch_row()從資料集取得的陣列,索引值只能是數字(數字索引)。
$a=$row[0];
引用至:
http://seanphpbook.blogspot.tw/2010/05/php-mysqlfetcharray-mysqlfetchassoc.html
沒有留言:
張貼留言