duanjiao4763 2013-10-08 16:09 采纳率: 0%
浏览 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.

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

报告相同问题?

悬赏问题

  • ¥50 关于#html5#的问题:H5页面用户手机返回的时候跳转到指定页面例如(语言-javascript)
  • ¥15 无法使用此凭据登录,因为你的域不可用,如何解决?(标签-Windows)
  • ¥15 yolov9的训练时间
  • ¥15 二叉树遍历没有报错但无法正常运行
  • ¥15 在linux系统下vscode运行robocup3d上场球员报错
  • ¥15 Python语言实验
  • ¥15 SAP HANA SQL 增加合计行
  • ¥20 用C#语言解决一个英文打字练习器,有偿
  • ¥15 srs-sip外部服务 webrtc支持H265格式
  • ¥15 在使用abaqus软件中,继承到assembly里的surfaces怎么使用python批量调动