2016-11-04 81 views
0
Array 
(
    [0] => Array 
     (
      [0] => 1 
      [id] => 1 
      [1] => 1 
      [candi_id] => 1 
      [2] => 
      [title] => 
      [3] => Lakshmanan 
      [firstname] => Lakshmanan 
      [4] => P 
      [lastname] => P 
      [5] => Male 
      [gender] => Male 
      [6] => Tamil 
      [mothertongue] => Tamil 
      [7] => 31-01-1990 
      [dob] => 31-01-1990 
      [8] => Hindu 
      [religion] => Hindu 
      [9] => O+ 
      [bloodgroup] => O+ 
      [10] => Single 
      [marital_status] => Single 
      [11] => Mettupalayam 
      [native] => Mettupalayam 
      [12] => Indian 
      [nationality] => Indian 
      [13] => Active 
      [status] => Active 
      [14] => 2016-11-04 
      [cdate] => 2016-11-04 
     ) 

) 

我想只獲得列值。但爲什麼我得到數組索引的值?爲什麼數組返回值與數組索引值?

+0

您是否從mysql數據庫獲取數據與mysql函數? –

+0

是的先生我用mysql取數組() – user5697399

+0

使用此mysql_fetch_array($結果,MYSQL_ASSOC) –

回答

0

首先我想說mysql函數已被棄用。所以現在繼續使用mysqliPDO更適合mysqldatabse的功能。

沒有任何參數mysql_fetch_array函數將輸出DB記錄在indexcolumn-name這兩種格式。

要獲得數據column-name只有你應該已經通過第二個參數「MYSQL_ASSOC」在mysql_fetch_array功能或代替你可以使用mysql_fetch_assoc功能以及。

$result = mysql_fetch_assoc($mysql_query);