doutao1171 2015-07-22 11:07
浏览 56

在通过PHP IF循环时显示图表

I'm working on showing the data from the DB using html table and google charts. In one part of the script im using an IF loop,that is very important.It operates the things that's gonna be shown on the screen.But the IF loop doesn't work like it should be.

<?php if($IF==3){ ?>


<div class='row'>
    <div class='col-md-4'>
        <div id="first" style="width: 900px; height: 500px;"></div>
    </div>
    <div class='col-md-4'>
        <div id="second" style="width: 900px; height: 500px;"></div>
    </div>
    <div class='col-md-4'>
        <div id="third" style="width: 900px; height: 500px;"></div>
    </div>
</div>

<?php
} else if($IF==2){ ?>
<div class='row'>
    <div class='col-md-6'>
        <div id="first" style="width: 900px; height: 500px;"></div>
    </div>
    <div class='col-md-6'>
        <div id="second" style="width: 900px; height: 500px;"></div>
    </div>

</div>
<?php }else{?>      

<div class='row'>   
    <div class='col-md-12'>         
        <div id="first" style="width: 900px; height: 500px;"></div> 
    </div>

</div>  

<?php } ?>  

Let's explain what i wanted to do here.If the variable $IF equals 3 (number of employees) it shows 3 pie charts,and this part works.It shows the right data and the right amount of pie charts. But the problem appears when $IF<2. The pie charts won't show. Am i doing this the wrong way? Thx in advance.

  • 写回答

1条回答 默认 最新

  • drlndkhib08556095 2015-08-31 12:47
    关注

    I've solved the problem,when I was creating the charts for 3 employees i had to send 3 different types of data in the script.BUT,when there were only 2 or 1 employee the variables that saved the data for the second or third were empty,and that created an error.It couldn't create a chart when the variables were empty.So i just added a simple IF loop to manage that

    评论

报告相同问题?

悬赏问题

  • ¥60 求一个简单的网页(标签-安全|关键词-上传)
  • ¥35 lstm时间序列共享单车预测,loss值优化,参数优化算法
  • ¥15 基于卷积神经网络的声纹识别
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP