Reputation: 95
I want get the results of mysql_fetch_assoc as an array then echo a specific value in that array. How do I do that? I tried
$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.
I'm just getting Array as a result.
Upvotes: 1
Views: 2474
Reputation: 57322
mysql_fetch_array
Returns an array that corresponds to the fetched row and moves the internal data pointer ahead.
now here
$d[] = $row_dates;
what you assigning to $d[]
is array instead value (i think what you want)
to check what you getting use var_dump()
to var_dump($row_dates);
and now what you
while($row_dates = mysql_fetch_array($date_result)){
$d[] = $row_dates['your_column_name'];
}
Upvotes: 0
Reputation: 30488
use the below code
$d = array();
while($row_dates = mysql_fetch_array($date_result)){
$d[] = $row_dates['your_column_name'];
}
you just miss the column_name
in your code, everything else in your code is fine.
Upvotes: 1