为什么数组返回值与数组索引值?

时间:2016-11-04 05:57:40

标签: php jquery html arrays

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
        )

)

我想只得到列值。但为什么我得到带有值的数组索引?

1 个答案:

答案 0 :(得分:0)

首先,我想说mysql函数已被弃用。因此,现在继续使用mysqliPDO更适合mysql databse功能。

如果没有任何参数,mysql_fetch_array函数会以DBindex两种格式输出column-name条记录。

要将数据设为column-name,您只需要在MYSQL_ASSOC函数中传递第二个参数“mysql_fetch_array”,或者也可以使用mysql_fetch_assoc函数。

$result = mysql_fetch_assoc($mysql_query);