Jpgraph:数据库数据可以';t使用php插入条形图

Jpgraph:数据库数据可以';t使用php插入条形图,php,mysql,database,jpgraph,Php,Mysql,Database,Jpgraph,这是我的密码: <?php // content="text/plain; charset=utf-8" require_once ('jpgraph/jpgraph.php'); require_once ('jpgraph/jpgraph_bar.php'); include("mysql _connect .php"); $code="CSC1113"; $ac_yr="2010/2011"; $sql = "SELECT results, COUNT(*) 'No_Of_gra

这是我的密码:

<?php 
// content="text/plain; charset=utf-8"
require_once ('jpgraph/jpgraph.php');
require_once ('jpgraph/jpgraph_bar.php');
include("mysql _connect .php");

$code="CSC1113";
$ac_yr="2010/2011";
$sql = "SELECT results, COUNT(*) 'No_Of_grades' FROM std_results WHERE code='$code' && ac_year='$ac_yr' GROUP BY results ORDER BY results ASC";
    $result = mysql_query($sql) or die(mysql_error());
    while($ors = mysql_fetch_array($result)) {
    $grd=$ors['results'];
    switch ($grd)
{
case "A":
  $datay[1]=$ors['No_Of_grades'];
  break;
case "A+":
  $datay[0]=$ors['No_Of_grades'];
  break;
case "A-":
  $datay=$ors['No_Of_grades'];
  break;
  case "B":
  $datay[4]=$ors['No_Of_grades'];
  break;
  case "B+":
  $datay[3]=$ors['No_Of_grades'];
  break;
  case "B-":
  $datay[5]=$ors['No_Of_grades'];
  break;
 case "C":
  $datay[7]=$ors['No_Of_grades'];
  break;
  case "C+":
  $datay[6]=$ors['No_Of_grades'];
  break;
  case "C-":
  $datay[8]=$ors['No_Of_grades'];
  break;
  case "D":
  $datay[10]=$ors['No_Of_grades'];
  break;
  case "D+":
  $datay[9]=$ors['No_Of_grades'];
  break;
  case "E":
  $datay[11]=$ors['No_Of_grades'];
  break;
  case "AB":
  $datay[12]=$ors['No_Of_grades'];
  break;
  case "NE":
  $datay[13]=$ors['No_Of_grades'];
  break;
default:
  $datay[14]=$ors['No_Of_grades'];
}

    }

    //set vlaue zero for othe grades..
    for($i=0;$i<15;$i++){
        if(!isset($datay[$i])){
            $datay[$i]=0;
            }

        }


// Create the graph. These two calls are always required
$graph = new Graph(550,320,'auto');
$graph->SetScale("textlin");

//$theme_class="DefaultTheme";
//$graph->SetTheme(new $theme_class());

// set major and minor tick positions manually
$graph->yaxis->SetTickPositions(array(0,4,8,12,16,20), array(2,6,10,14,18));
$graph->SetBox(false);

//$graph->ygrid->SetColor('gray');
$graph->ygrid->SetFill(false);
$graph->xaxis->SetTickLabels(array('A+','A','A-','B+','B','B-','C+','C','C-','D+','D','E','AB','NE','MC'));
$graph->yaxis->HideLine(false);
$graph->yaxis->HideTicks(false,false);

// Create the bar plots
$b1plot = new BarPlot($datay);

// ...and add it to the graPH
$graph->Add($b1plot);


$b1plot->SetColor("white");
$b1plot->SetFillGradient("#4B0082","white",GRAD_LEFT_REFLECTION);
$b1plot->SetWidth(25);
$graph->title->Set("Bar Gradient(Left reflection)");

// Display the graph
$graph->Stroke();
?>

我的代码有什么问题…无法理解…请帮助我…高级中的thanxx…

我想现在我了解您了:

case "A-":
  $datay=$ors['No_Of_grades'];
  break;
应该是:

case "A-":
  $datay['2']=$ors['No_Of_grades'];
  break;

这是我的表格:这是什么:'没有分数'?我从sql查询上面得到的一个列名…看这个图片:代码看起来不错,问题是查询“我想”。此外,您还应该了解MYSQLI或PDO,Mysql已经被取消,将不会在将来的版本中使用。“No_of_grades”来自的表的名称是什么。No dear No_of_grades是列的名称,它的frm计数(*)“No_of_grades”…dear此sql查询正常..它没有问题..问题是无法将数据惰性化到此grpagh它显示错误:JpGraph错误:25067您手动指定的刻度和刻度不正确。刻度似乎太小,无法容纳任何指定的记号。
case "A-":
  $datay['2']=$ors['No_Of_grades'];
  break;