Ben Ben - 1 month ago 4x
MySQL Question

Reference specific row's column value from array

I have read a-lot of answers on this but they don't seem to be working.

I have the following code:

$amountoflikes=mysql_query("SELECT * FROM `uc_likes` WHERE `dwable` = '372'");

This returns the following:

enter image description here

If I wanted to echo the value of
in the 2nd row for instance (not involving the initial query).

I've tried:

while($row3 = mysql_fetch_assoc($amountoflikes)){
$json[] = $row3;
echo json_encode($json);

But this returns null.

I'm currently using PHP 5.5 (native).

I'm not using MySQLi or MySQL PDO.

Can someone tell me where I'm going wrong. Ideally I'd prefer not to use a loop but I don't know if that's possible.



Try declaring $json as an array above the while:

$json = array();