duanjiao4763 2013-10-08 16:09
浏览 55
已采纳

PHP,谷歌图表到Joomla网站

I try to integrate Google Pie Chart to my Joomla 3.1 website in a bit of tricky way. The chart is going to take data from the database and show it on the front-end.

Instead of the standard way to put data

['Work', 11]

I put it this way

["<?php echo $params->get('label_1')?>", <?php echo $results1?>],

["<?php echo $params->get('label_2')?>", <?php echo $results2?>],

and everything is all right. PHP takes data from my administrator panel, where I put a value for label_1 and it takes result1 after making some calculations with data in the database. Everything works correctly.

The problem comes when for example I have no data in the database for $result2 to calculate while everything is ok with $result1. I made a switcher to hide or show specific parameters and made this code for it

<?php if ($this->item->params->get('cpn_1')):           
          echo '["' . $params->get('label_1') . $result1 . '],';
        endif;?>

but it does not work and I cannot find where the mistake is. This should check if I switched on or off the specific part of the chart to be displayed on the front-end. After I create the page from where the data should be taken from database I switch on the piece of the chart from my back-end and it should work.

I also consider there should be a better way to do all this. The problem is that this is going to be a module and in case some day some tables or columns from database will be empty the page will not load at all.

  • 写回答

1条回答 默认 最新

  • doutuohan6606 2013-10-09 07:44
    关注

    If it's a module it will definitely not be $this->item->params but just $params eg:

    <?php if ($params->get('cpn_1')):           
        echo '["' . $params->get('label_1') . '", ' . $result1 . '],';
    endif;?>
    

    Edit: Also you where missing quote-marks and a comma after label1.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥20 机器学习能否像多层线性模型一样处理嵌套数据
  • ¥20 西门子S7-Graph,S7-300,梯形图
  • ¥50 用易语言http 访问不了网页
  • ¥50 safari浏览器fetch提交数据后数据丢失问题
  • ¥15 matlab不知道怎么改,求解答!!
  • ¥15 永磁直线电机的电流环pi调不出来
  • ¥15 用stata实现聚类的代码
  • ¥15 请问paddlehub能支持移动端开发吗?在Android studio上该如何部署?
  • ¥20 docker里部署springboot项目,访问不到扬声器
  • ¥15 netty整合springboot之后自动重连失效