|
|
|
สอบถามเรื่่องของ jpgraph หน่อยค่ะ พอดีขึ้นภาษาไทยแค่อันสุดท้ายอ่าค่ะ |
|
|
|
|
|
|
|
พอดีรันแล้วขึ้นภาษาไทยแค่ชื่ออาจารย์คนสุดท้ายเท่านั้นอ่าค่ะ อันอื่นๆๆไม่ขึ้นเลย รบกวนด้วยน่ะค่ะ
Code (PHP)
<?php
include("../JpGraph/src/jpgraph.php");
include("../JpGraph/src/jpgraph_line.php");
require_once('../connect/Connect.php');
if(empty($_POST['subjectid'])&&empty($_POST['id'])){?>
<script language="javascript">
alert("ไม่ได้ระบุวิชา"); location.href='Graph1_Select.php';
</script>
<? }
elseif(!empty($_POST['subjectid'])&&!empty($_POST['id'])){?>
<script language="javascript">
alert("กรุณาระบุอย่างใดอย่างหนึ่ง"); location.href='Graph1_Select.php';
</script>
<? }
else{
if(empty($_POST['subjectid'])){
$id=$_POST['id'];
$resultcheck=mysql_query("SELECT * FROM subject WHERE Subject_Id='$id'");
if(mysql_num_rows($resultcheck)==0){?>
<script language="javascript">
alert("ระบุรหัสวิชาไม่ถูกต้อง"); location.href='Graph1_Select.php';
</script>
<? }
}
else{
$id=$_POST['subjectid'];
}
}
$resultcheck2=mysql_query("SELECT * FROM reassess WHERE(Subject_Id='$subjectid')");
if(mysql_num_rows($resultcheck2)==0){?>
<script language="javascript">
alert("ไม่พบรายงานการประเมิน"); location.href='Graph1_Select.php';
</script>
<? }
else{
$g = new Graph(500, 650);
$g->SetScale("textlin");
$resultreassess=mysql_query("SELECT * FROM reassess WHERE Subject_id='$id'");
$datareassess=mysql_fetch_array($resultreassess);
$subjectid=$datareassess['Subject_Id'];
$resultsubject=mysql_query("SELECT * FROM subject WHERE Subject_Id='$subjectid'");
$datasubject=mysql_fetch_array($resultsubject);
//แสดงส่วนบน
$head=$datasubject['Subject_Id']." วิชา ".$datasubject['Subject_NameThai'];
$title = iconv("tis620", "utf-8", $head);
$g->title->Set($title);
$g->title->SetFont(FF_JASMINE, FS_BOLD, 16);
$g->title->SetColor("black");
//หารายชื่ออาจารย์
$sqlreassess="SELECT DISTINCT(Teacher_Id) FROM reassess WHERE (Subject_Id='$subjectid') ORDER BY Teacher_Id ASC";
$resultreassess=mysql_query($sqlreassess)or die ("no sqlteacher");
$numreassess=mysql_num_rows($resultreassess);
$k=0;
if(mysql_num_rows($resultreassess)<2){?>
<script language="javascript">
alert("ไม่สามารถเปรียบเทียบข้อมูลได้"); location.href='Graph1_Select.php';
</script>
<? exit; }
while($datareassess=mysql_fetch_array($resultreassess)){
$teachid=$datareassess['Teacher_Id'];
$resultteacher=mysql_query("SELECT * FROM teachar WHERE Teacher_Id='$teachid'");
$datateacher=mysql_fetch_array($resultteacher);
$labels[$k] =$datateacher['Teacher_Fname']." ".$datateacher['Teacher_Lname'];
//แสดงชื่อนามสกุลอาจารย์
for($n=0;$n<$numreassess;$n++){
//echo "tea : ".$printteacher[$n] ."<br>";
//echo "point : ".$printresult[$n]."<br>";
$labels[$n]=iconv("tis-620", "utf-8", $labels[$n]);
}
$g->xaxis->SetTickLabels($labels);
$g->xaxis->SetFont(FF_JASMINE, FS_NORMAL,14);
$g->xaxis->SetLabelAngle(45);
//point
$sqlselect="SELECT * FROM reassess WHERE(Teacher_Id='$teachid')AND(Subject_Id='$subjectid');";
$resultselect=mysql_query($sqlselect)or die ("no sqlselect");
$numselect=mysql_num_rows($resultselect);
//ลบคะแนนทั้งหมดให้เป็น0
for($clear=0;$clear<30;$clear++){
$question[$clear]=0;
}
while($dataselect=mysql_fetch_array($resultselect)){
$question[1]=$question[1]+ $dataselect[Ques1];
$question[2]=$question[2]+ $dataselect[Ques2];
$question[3]=$question[3]+ $dataselect[Ques3];
$question[4]=$question[4]+ $dataselect[Ques4];
$question[5]=$question[5]+ $dataselect[Ques5];
$question[6]=$question[6]+ $dataselect[Ques6];
$question[7]=$question[7]+ $dataselect[Ques7];
$question[8]=$question[8]+ $dataselect[Ques8];
$question[9]=$question[9]+ $dataselect[Ques9];
$question[10]=$question[10]+ $dataselect[Ques10];
$question[11]=$question[11]+ $dataselect[Ques11];
$question[12]=$question[12]+ $dataselect[Ques12];
$question[13]=$question[13]+ $dataselect[Ques13];
$question[14]=$question[14]+ $dataselect[Ques14];
$question[15]=$question[15]+ $dataselect[Ques15];
$question[16]=$question[16]+ $dataselect[Ques16];
$question[17]=$question[17]+ $dataselect[Ques17];
$question[18]=$question[18]+ $dataselect[Ques18];
$question[19]=$question[19]+ $dataselect[Ques19];
$question[20]=$question[20]+ $dataselect[Ques20];
$question[21]=$question[21]+ $dataselect[Ques21];
$question[22]=$question[22]+ $dataselect[Ques22];
$question[23]=$question[23]+ $dataselect[Ques23];
$question[24]=$question[24]+ $dataselect[Ques24];
$question[25]=$question[25]+ $dataselect[Ques25];
$question[26]=$question[26]+ $dataselect[Ques26];
$question[27]=$question[27]+ $dataselect[Ques27];
$question[28]=$question[28]+ $dataselect[Ques28];
$question[29]=$question[29]+ $dataselect[Ques29];
$question[30]=$question[30]+ $dataselect[Ques30];
}
//จำนวนนักศึกษาที่ประเมินสำหรับวิชานั้นๆ
$numstu=mysql_num_rows($resultselect);
//นำคะแนนมาคูณจำนวนนักศึกษา
$point=$numstu*5;
//คะแนนข้อย่อย
$sqlsub="SELECT * FROM sub ORDER BY Sub_No ASC";
$resultsub=mysql_query($sqlsub)or die ("no sqlsub");
$numsub=mysql_num_rows($resultsub);
//เคลียร์ค่า
$resultsumsub=0;
for($i=1;$i<=$numsub;$i++){
$resultques[$i]=($question[$i]/$point)*100;
$resultques[$i]=round($resultques[$i],2);
$resultsumsub=$resultsumsub+$resultques[$i];
}
$resultsum= $resultsumsub/$numsub;
$printresult[$k]= round($resultsum,2);
$k++;
}
//แสดงคะแนน
for($n=0;$n<$numreassess;$n++){
$data[$n]=$printresult[$n];
}
$line = new LinePlot($data);
$line->Setcolor("green");
$line->value->Show();
$line->value->SetColor("red");
$line->mark->SetType(MARK_SQUARE);
$line->SetLegend("");
$g->Add($line);
$g->Stroke();
}
?>
</body>
</html>
-----------------------------------------------------------------------
นี่อ่าค่ะ ภาพตัวอย่างตอนรันแล้ว
Tag : PHP
|
|
|
|
|
|
Date :
2010-12-22 20:09:50 |
By :
n_t |
View :
1350 |
Reply :
2 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
อยากทราบวิธีการทำกราฟบ้างค่ะ
|
|
|
|
|
Date :
2010-12-27 09:54:29 |
By :
wongkhajang |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 05
|