Php mysql\u fetch\u assoc echo特定行值

Php mysql\u fetch\u assoc echo特定行值,php,get,Php,Get,我希望将mysql_fetch_assoc的结果作为一个数组获取,然后在该数组中回显一个特定值。我该怎么做?我试过了 $d = array(); while($row_dates = mysql_fetch_array($date_result)){ $d[] = $row_dates; } echo $d[1];// this would be the result from the first row echo $d[3];// this should be the result from

我希望将mysql_fetch_assoc的结果作为一个数组获取,然后在该数组中回显一个特定值。我该怎么做?我试过了

$d = array();
while($row_dates = mysql_fetch_array($date_result)){
$d[] = $row_dates;
}

echo $d[1];// this would be the result from the first row
echo $d[3];// this should be the result from the second row.
我只是得到一个数组作为结果。

使用下面的代码

$d = array();
while($row_dates = mysql_fetch_array($date_result)){
    $d[] = $row_dates['your_column_name'];
}
您只是错过了代码中的
列\u name
,代码中的其他所有内容都没有问题。

请使用下面的代码

$d = array();
while($row_dates = mysql_fetch_array($date_result)){
    $d[] = $row_dates['your_column_name'];
}
mysql_fetch_array
您只是错过了代码中的
列\u name
,代码中的其他内容都很好

mysql_fetch_array
返回与获取的行相对应的数组,并将内部数据指针向前移动

现在在这里

$d[] = $row_dates;
您分配给
$d[]
的是数组而不是值(我想您需要的是)

使用
var\u dump()
var\u dump($row\u dates)检查您得到了什么

现在你要做什么

while($row_dates = mysql_fetch_array($date_result)){
    $d[] = $row_dates['your_column_name'];
}
返回与获取的行相对应的数组,并将内部数据指针向前移动

现在在这里

$d[] = $row_dates;
您分配给
$d[]
的是数组而不是值(我想您需要的是)

使用
var\u dump()
var\u dump($row\u dates)检查您得到了什么

现在你要做什么

while($row_dates = mysql_fetch_array($date_result)){
    $d[] = $row_dates['your_column_name'];
}

MYSQL函数现在已被弃用。因此,请使用MYSQLi或PDO升级您的代码。它是recommended@EdwinAlexMYSQL未被弃用,但
MYSQL\uuz
函数已被弃用;)。它们不再得到维护。看到了吗?相反,学习,并使用or-将帮助您决定哪一个。如果选择PDO,.MYSQL函数现在不推荐使用。因此,请使用MYSQLi或PDO升级您的代码。它是recommended@EdwinAlexMYSQL未被弃用,但
MYSQL\uuz
函数已被弃用;)。它们不再得到维护。看到了吗?相反,学习,并使用or-将帮助您决定哪一个。如果您选择PDO。