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.

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

报告相同问题?

悬赏问题

  • ¥15 三菱伺服电机按启动按钮有使能但不动作
  • ¥20 为什么我写出来的绘图程序是这样的,有没有lao哥改一下
  • ¥15 js,页面2返回页面1时定位进入的设备
  • ¥200 关于#c++#的问题,请各位专家解答!网站的邀请码
  • ¥50 导入文件到网吧的电脑并且在重启之后不会被恢复
  • ¥15 (希望可以解决问题)ma和mb文件无法正常打开,打开后是空白,但是有正常内存占用,但可以在打开Maya应用程序后打开场景ma和mb格式。
  • ¥20 ML307A在使用AT命令连接EMQX平台的MQTT时被拒绝
  • ¥20 腾讯企业邮箱邮件可以恢复么
  • ¥15 有人知道怎么将自己的迁移策略布到edgecloudsim上使用吗?
  • ¥15 错误 LNK2001 无法解析的外部符号