I trying to insert SQL query results to PHP array:
$sql= $conn -> prepare("SELECT top(10) code, name, SUM(minutes)as total FROM db_name group by code, name ORDER BY total desc");
$sql -> execute();
$combinedResults = array();
while ($row = $sql -> fetch(PDO::FETCH_ASSOC)) {
$combinedResults[$row['code']][] = array(
'Name' => $row['name'],
'Total' => $row['total'] );
};
echo($combinedResults['code'][0]['Total']);
?>
and script return Undefined index: code in echo row