开发者

Drupal 6 FusionChart PHP database data display

I am trying to get a pie chart display co开发者_如何学Pythonrrectly 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..


$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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜