| 
           | 
        
        
          
			
			  
			    
					
					茫茫網海中的冷日					 
					
					發生過的事,不可能遺忘,只是想不起來而已!									 | 
		       
			  
				| 
				   | 
				
					 
					 恭喜您是本站第 1746961 
										位訪客!
					 登入  | 註冊 
					 
				 | 
				
				  
					
			      			     | 
			   
			 
		   | 
        
      
      
        
                      
              
                                      
		                                       
		                                       
		                                       
		                                       
		                                       
		                             
			 | 
                          
                
                                    
                    
                      
	| 發表者 | 
	討論內容 | 
 
	 冷日 (冷日) | 
	發表時間:2014/3/5 9:02 | 
 
	
	
	- Webmaster
 
		  
	 
	 
	
		- 註冊日: 2008/2/19
 
		- 來自: 
 
		- 發表數: 15773
 
			 
	 | 
	
	
	- [轉貼] mysql_fetch_array() 與 mysql_fetch_assoc() 與 mysql_fetch_row() 的差異
 
		- [PHP] mysql_fetch_array() 與 mysql_fetch_assoc() 與 mysql_fetch_row() 的差異
 當需要從DB讀取資料時,我們常會使用下列的語法:
while ($row = mysql_fetch_array($result)){
    $xxx = $row['a'];
}
  但是,有時候也會看到 mysql_fetch_assoc() 或 mysql_fetch_row() ,差別在於...
  mysql_fetch_array() 從資料集取得的陣列,索引值可以是數字(數字索引)或字串(關聯索引)。
$a=$row[0]; 或 $a=$row["a"]; 
  mysql_fetch_assoc() 從資料集取得的陣列,索引值只能是字串(關聯索引)。
  mysql_fetch_row() 從資料集取得的陣列,索引值只能是數字(數字索引)。
 
  所以,如果你想要讓陣列可以用數字當索引,同時也能用字串當索引,那就用 mysql_fatch_array() 吧。
 
 
  原文出處:謝晒的PHP網頁設計: [PHP] mysql_fetch_array() 與 mysql_fetch_assoc() 與 mysql_fetch_row() 的差異 
	 
	 | 
 
	| 
	
	
	 | 
 
| 
 | 
 
 
 
討論串
 
 
 
                       |