score:2

Accepted answer

You'd first have to build the non-db-related parts into your PHP structure, e.g.

$data = array(
   0 => array(
        'name' => 'Female',
        'marker' => array (
             'symbol': 'circle'
             etc....),
        'data' => array() // database insertion occurs here
        ),
   1 => array(
        'name' => 'Male',
        etc...
        )
);

$locations = array('Female' => 0, 'Male' => 1, etc...) // reverse map your 'name' fields

while(...) {
     $data[$locations[$row['name']]][data]['x'][] = $row['price'];
     $data[$locations[$row['name']]][data]['y'][] = $row['quantity'];
           ^^^^^^^^^^^^^^^^^^^^^^^^--- reverse lookup to get right array index for 'name'
}

score:0

First I'm going to recommend you take a look at your SQL query, especially the part of WHERE id=$1. If I'm not mistaken (and on this I'm fairly sure.) your query is going to return one (1) row not many like what you probably want. I would recommend removing the WHERE clause and see if that solves your problem.

If not drop me a line and I'll see what else I see and we can go from there.


Related Query

More Query from same tag