CREATE TABLE `therapy` (
`the_id` int(10) NOT NULL,
`pat_hn` int(10) NOT NULL,
`ot_id` tinyint(2) NOT NULL,
`the_treat` text collate utf8_unicode_ci NOT NULL,
`the_date` date NOT NULL,
PRIMARY KEY (`the_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
--
-- dump ตาราง `therapy`
--
INSERT INTO `therapy` VALUES (1, 6666666, 5, 'ปั่นจักรยาน', '2012-03-05');
INSERT INTO `therapy` VALUES (2, 5018107, 5, '', '2011-05-12');
INSERT INTO `therapy` VALUES (8, 4631987, 5, 'ยกถุงทราย', '2012-04-08');
INSERT INTO `therapy` VALUES (9, 4706928, 5, 'ใส่ห่วง', '2007-08-16');
INSERT INTO `therapy` VALUES (11, 4616632, 5, 'โยนลูกบอล', '2012-04-10');
INSERT INTO `therapy` VALUES (13, 4616632, 3, 'หนึบไม้หนีบผ้า', '2012-04-17');
INSERT INTO `therapy` VALUES (14, 4616632, 3, 'หนึบไม้หนีบผ้า', '2012-04-17');
INSERT INTO `therapy` VALUES (16, 4630800, 3, 'เดินออกกำลังกาย', '2012-04-19');
INSERT INTO `therapy` VALUES (17, 4632597, 3, 'ตักทราย', '2012-04-21');
INSERT INTO `therapy` VALUES (18, 4730573, 4, 'ดึงเชือก', '2012-04-22');
INSERT INTO `therapy` VALUES (19, 4835394, 5, 'หยิบลูกบอลใส่ตระกร้า', '2012-04-17');
INSERT INTO `therapy` VALUES (20, 5111647, 4, 'ยกถุงทราย', '2012-04-23');
INSERT INTO `therapy` VALUES (21, 5107188, 5, 'คีบลูกปิงปอง', '2012-04-23');
INSERT INTO `therapy` VALUES (22, 5318668, 4, 'ฝึกมือ', '2012-04-23');
INSERT INTO `therapy` VALUES (23, 5316452, 3, 'ฝึกใช้ช้อนส้อม', '2012-04-23');
INSERT INTO `therapy` VALUES (24, 5313192, 3, 'ฝึกใส่เสื้อผ้า', '2012-04-23');
INSERT INTO `therapy` VALUES (25, 5305947, 3, 'ฝึกพูด', '2012-04-23');
INSERT INTO `therapy` VALUES (26, 5300657, 2, 'ปั่นจักรยานมือ', '2012-04-23');
INSERT INTO `therapy` VALUES (28, 4600225, 1, 'วันที่ 1', '2012-05-15');
INSERT INTO `therapy` VALUES (29, 4600225, 1, 'วันที่ 2', '2012-05-16');
INSERT INTO `therapy` VALUES (30, 4600225, 2, 'วันที่ 3', '2012-05-17');
INSERT INTO `therapy` VALUES (31, 4600225, 2, 'วันที่ 4', '2012-05-18');
INSERT INTO `therapy` VALUES (32, 4600225, 3, 'วันที่ 5', '2012-05-19');
INSERT INTO `therapy` VALUES (33, 4600225, 3, 'วันที่ 6', '2012-05-20');
INSERT INTO `therapy` VALUES (34, 4600225, 4, 'วันที่ 7', '2012-05-21');
INSERT INTO `therapy` VALUES (36, 4606611, 5, 'วันที่ 1', '2012-05-15');
INSERT INTO `therapy` VALUES (37, 4608995, 4, 'วันที่ 1', '2012-05-15');
INSERT INTO `therapy` VALUES (38, 4812493, 3, 'ทดสอบ', '2012-05-23');
INSERT INTO `therapy` VALUES (39, 4812493, 1, 'ทดสอบการวิ่ง', '2012-05-22');
INSERT INTO `therapy` VALUES (40, 4812493, 1, '', '2012-05-21');
INSERT INTO `therapy` VALUES (41, 4600225, 5, 'เดินบันได', '2012-05-23');
INSERT INTO `therapy` VALUES (42, 4815289, 4, 'ปั่นจักรยาน', '2012-05-23');
<?php
include("config.php");
include (".../jpgraph/jpgraph.php");
include (".../jpgraph/jpgraph_bar.php");
// ติดต่อ ฐานข้อมูล เลือกข้อมูลขึ้นมาเพื่อแสดงกราฟ
$strSQL = "SELECT t.ot_id as ot_id, COUNT(t.ot_id) as count_ot_id FROM therapy AS t GROUP BY t.ot_id";
$objQuery = mysql_query($strSQL) or die ("Error Query [".$strSQL."]");
// เตรียมข้อมุลที่จะแสดง เพื่อสร้างกราฟ
$datay=array();
while($objResult = mysql_fetch_array($objQuery))
{
$datay[] = $objResult["ot_id"];
}
//$datay = array();
// Create the graph.
$graph = new Graph(600,400);
$graph->SetScale("textlin");
$graph->SetMarginColor('navy:1.9');
$graph->SetBox();
// Create and add a new text
$txt=new Text('ทดสอบ');
$txt->SetPos(10,20);
$txt->SetColor('darkred');
$txt->SetFont(FF_ANGSA,FS_BOLD,15);
$txt->SetBox('yellow','navy','[email protected]');
$graph->AddText($txt);
// Setup the titles
$graph->title->Set('ทดสอบ');
$graph->xaxis->title->Set('แกน-X');
$graph->yaxis->title->Set('แกน-Y');
$graph->title->SetFont(FF_ANGSA,FS_BOLD,18);
$graph->yaxis->title->SetFont(FF_ANGSA,FS_BOLD,18);
$graph->xaxis->title->SetFont(FF_ANGSA,FS_BOLD,18);
$graph->title->Set('ทดสอบ');
$graph->title->SetFont(FF_ANGSA,FS_BOLD,20);
$graph->SetTitleBackground('lightblue:1.3',TITLEBKG_STYLE2,TITLEBKG_FRAME_BEVEL);
$graph->SetTitleBackgroundFillStyle(TITLEBKG_FILLSTYLE_HSTRIPED,'lightblue','blue');
// Create a bar pot
$bplot = new BarPlot($datay);
$bplot->SetFillColor('darkorange');
$bplot->SetWidth(0.6);
$bplot->SetPattern(PATTERN_CROSS1,'navy');
$graph->Add($bplot);
$graph->Stroke();
?>
<?php
include("config.php");
include (".../jpgraph/jpgraph.php");
include (".../jpgraph/jpgraph_bar.php");
// ติดต่อ ฐานข้อมูล เลือกข้อมูลขึ้นมาเพื่อแสดงกราฟ
$strSQL = "SELECT o.ot_user as ot_user, Count(t.ot_id) as count_ot_id FROM therapy AS t INNER JOIN ot AS o ON o.ot_id = t.ot_id
GROUP BY o.ot_user";
$objQuery = mysql_query($strSQL) or die ("Error Query [".$strSQL."]");
// เตรียมข้อมุลที่จะแสดง เพื่อสร้างกราฟ
//$datay=array();
while($objResult = mysql_fetch_array($objQuery))
{
$datay[] = $objResult["count_ot_id"];
$datax[] = $objResult["ot_user"];
}
// Create the graph.
$graph = new Graph(600,400);
$graph->SetScale("textlin");
$graph->SetMarginColor('navy:1.9');
$graph->SetBox();
// Create and add a new text
$txt=new Text('ทดสอบ');
$txt->SetPos(10,20);
$txt->SetColor('darkred');
$txt->SetFont(FF_ANGSA,FS_BOLD,15);
$txt->SetBox('yellow','navy','[email protected]');
$graph->AddText($txt);
// Setup the titles
$graph->title->Set('ทดสอบ');
$graph->xaxis->title->Set('แกน-X');
$graph->yaxis->title->Set('แกน-Y');
$graph->title->SetFont(FF_ANGSA,FS_BOLD,18);
$graph->yaxis->title->SetFont(FF_ANGSA,FS_BOLD,18);
$graph->xaxis->title->SetFont(FF_ANGSA,FS_BOLD,18);
$graph->title->Set('ทดสอบ');
$graph->title->SetFont(FF_ANGSA,FS_BOLD,20);
$graph->SetTitleBackground('lightblue:1.3',TITLEBKG_STYLE2,TITLEBKG_FRAME_BEVEL);
$graph->SetTitleBackgroundFillStyle(TITLEBKG_FILLSTYLE_HSTRIPED,'lightblue','blue');
//Setup X-scale
//$graph->xaxis->SetTextTickInterval(10);
//$graph->xaxis->SetTickLabels($datax);
//$graph->xtick_factor = 1;
//$graph->xaxis->SetLabelAngle(30);
//$graph->xaxis->SetTickLabels(array('OT1','OT2','OT3','OT6','OT7'));
$graph->xaxis->SetTickLabels($datax);
// Create a bar pot
$bplot = new BarPlot($datay);
$bplot->SetFillColor('darkorange');
$bplot->SetWidth(0.6);
$bplot->SetPattern(PATTERN_CROSS1,'navy');
$graph->Add($bplot);
$graph->Stroke();
?>