drvonr6573 2013-12-31 11:34
浏览 34

无法通过饼图在PHP中传递值

I have a page1.php with image scr="pieGraph.php" inside it. And in my pieGraph.php i have a code like this:

session_start();
if(isset($_SESSION['test']))
{
  $_SESSION['test'] = $_SESSION['test'];
}
else
{ 
  $_SESSION['test'] = 0;
}

$val1 = $_SESSION['test'];
$val2 = 30;
$val3 = 40;
$val4 = 50;
$val5 = 10;
 /* CAT:Pie charts */ 

 /* pChart library inclusions */ 
 include("chart/class/pData.class.php"); 
 include("chart/class/pDraw.class.php"); 
 include("chart/class/pPie.class.php"); 
 include("chart/class/pImage.class.php"); 

 /* Create and populate the pData object */ 
 $MyData = new pData();    
 $MyData->addPoints(array($val1,$val2,$val3,$val4,$val5),"ScoreA");   
 $MyData->setSerieDescription("ScoreA","Application A"); 

 /* Render the picture (choose the best way) */ 
$myPicture->autoOutput("pictures/example.draw2DRingValue.png"); 
?>

But session in this page doesn't work. Dont know why. Please help guys.

  • 写回答

1条回答 默认 最新

  • dongxiang3205 2014-01-01 07:10
    关注

    Thanks for the help guys :)) I already solved my problem :))) Thanks for this link how to retrieve data from field name and column to generate graph

    So far this was my code:

     <?php
    date_default_timezone_set("Asia/Manila");
    session_start();
    include ("inc/dbcon.php"); 
    
    if(isset($_SESSION['campaign']))
    {
        $_SESSION['campaign'] = $_SESSION['campaign'];
    }
    else
    {
    $_SESSION['camapign'] = 'CEBU PACIFIC';
    } 
    if(isset($_SESSION['team']))
    {
    $_SESSION['team'] = $_SESSION['team'];
    }
    else
    {
    $_SESSION['team'] = 'TEAM AENNAH';
    } 
    if(isset($_SESSION['date']))
    {
    $_SESSION['date'] = $_SESSION['date'];
    }
    else
    {
    $_SESSION['date'] = "1999-01-01";
    } 
    
    $val1 = 100;
    $val2 = 30;
    $val3 = 40;
    $val4 = 50;
    $val5 = 10;
     /* CAT:Pie charts */ 
    
    /* pChart library inclusions */ 
    include("chart/class/pData.class.php"); 
    include("chart/class/pDraw.class.php"); 
    include("chart/class/pPie.class.php"); 
    include("chart/class/pImage.class.php"); 
    
    /* Create and populate the pData object */ 
    $MyData = new pData();    
    $query = mysql_query("SELECT * FROM tbl_projected WHERE          fd_campaign='$_SESSION[campaign]' AND fd_team='$_SESSION[team]' AND   fd_date='$_SESSION[date]'") or die(mysql_error());
    if(mysql_num_rows($query) == 0)
    {   
    $MyData->addPoints(array($val1,$val2,$val3,$val4,$val5),"ScoreA");   
    $MyData->setSerieDescription("ScoreA","Application A");
    }
    else 
    {
    while($row = mysql_fetch_array($query))
    {
    $MyData->addPoints(array($row['fd_Bill_Calling_hrs'], $row['fd_Bill_Training_hrs'],    $row['fd_Bill_Support_hrs'], $row['fd_Bill_OT_hrs'], $row['fd_Bill_HO_OT_hrs'])); 
    $MyData->setSerieDescription("ScoreA","Application A"); 
    }
     }  
    

    Hope this will help others too :))

    评论

报告相同问题?

悬赏问题

  • ¥17 pro*C预编译“闪回查询”报错SCN不能识别
  • ¥15 微信会员卡接入微信支付商户号收款
  • ¥15 如何获取烟草零售终端数据
  • ¥15 数学建模招标中位数问题
  • ¥15 phython路径名过长报错 不知道什么问题
  • ¥15 深度学习中模型转换该怎么实现
  • ¥15 HLs设计手写数字识别程序编译通不过
  • ¥15 Stata外部命令安装问题求帮助!
  • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
  • ¥15 TYPCE母转母,插入认方向