views:

33

answers:

1

Hello,

I am trying to get a pie chart display correctly but have found there to be not much documentation / guidance for drupal 6 and fusioncharts.

anyways im aiming to query the database with this:

$query = mysql_query("select * from content_type_engage");

Then i want to loop through the results and retrieve one specific value with

while ($row = mysql_fetch_assoc($query)) {
$n = $row['field_support_value'];}

Now this all works. but what i want to do is place each value from the database into an array.

i dont particularly understand multi-nested arrays so excuse me.

 $info->data = array(array('Cat', $n),
            array('Dog', $n),
            array('Pig', $n),
             array('Mouse', $n),
         );

i need each seperate value to go where '$n' is in this mutli-nested array.

Thanks for any help..

A: 
$info->data = array();
$query = db_query("select ???, field_support_value from {content_type_engage}");
while ($row = db_fetch_array($query)) {
  $info->data[] = array($row['???'], $row['field_support_value']);
}

It looks like your table is managed with the CCK. Direct DB access is probably a bad idea has it means you rely on the particular schema produced by Drupal and the CCK for the current configuration of your content type and its fields. You will have to test your code, and maybe fix, your code after each module or configuration update.

$info->data = array();
$results = db_query("SELECT nid FROM {node} WHERE type = '%s'", YOURCONTENTTYPE);
while ($nid = db_result($results)) {
  $node = node_load($nid);
  $info->data = array($node->???, $node->field_support_value);
}

This solution is not very good performance wise (one query for each loaded node). But it should help you to get things right.

mongolito404