• Jpgraph小应用


     1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
     2 <html xmlns="http://www.w3.org/1999/xhtml">
     3 <head>
     4 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
     5 <title>成绩查询</title>
     6 </head>
     7 
     8 <body>
     9 <?php
    10     include('conn.php');
    11     $sql = 'select distinct(km) from tb_grade';
    12     $r = mysql_query($sql);
    13     
    14 ?>
    15 <form action="lx3do.php" method="post">
    16     请选择要查询成绩的科目:
    17     <select name="sel">
    18       <?php
    19               while($row = mysql_fetch_array($r)){
    20                 echo '<option value="'.$row['km'].'">';
    21                 echo $row['km'];
    22                 echo '</option>';
    23             }
    24       ?>
    25             
    26     </select>
    27     <input type="submit" value="查询" name="sub"/>
    28 </form>
    29 </body>
    30 </html>
    <?php
    header ( "Content-type: text/html; charset=UTF-8" ); 
    require_once 'Jpgraph/jpgraph.php';     
    require_once 'Jpgraph/jpgraph_bar.php';    
    include('conn.php');
    $sel =$_POST['sel'];
    $sql = "select * from tb_grade where km='$sel'";
    $r = mysql_query($sql);
    while ($row=mysql_fetch_array($r)) {
        $data[] = $row['xh'];
        $datas[] = $row['cj'];
    }
    $graph = new Graph(600, 600);    
    $graph->SetScale("textlin",0,100);     
    $graph->SetShadow();    
    
    $graph->img->SetMargin(60, 10, 60, 80);   
    $barplot = new BarPlot($datas);    
    
    $graph->Add($barplot);
    
    $barplot->value->Show();
    $graph->title->Set(iconv("utf-8","gb2312","数学成绩"));   
    $graph->xaxis->title->Set(iconv("utf-8","gb2312","学号"));    
    $graph->xaxis->SetTickLabels($data);
    $graph->yaxis->title->Set(iconv("utf-8","gb2312",'成绩(百分比)'));    
    $graph->title->SetFont(FF_SIMSUN, FS_BOLD);     
    $graph->xaxis->title->SetFont(FF_SIMSUN,FS_BOLD);   
    $graph->yaxis->title->SetFont(FF_SIMSUN,FS_BOLD);   
    $graph->Stroke();     
    ?>
    1 <?php
    2     header("content-type:text/html;charset=utf-8");
    3     $conn = mysql_connect("localhost","root","") or die("连接服务器失败");
    4     mysql_select_db("db_test8");
    5     mysql_query("set names utf8");
    6 ?>
  • 相关阅读:
    MVC 路由规则
    MVC系统过滤器、自定义过滤器
    MVC部署
    MVC 读书笔记
    C# 调用 Web Service
    RESTful 架构
    WebSocket C# Demo
    C# 编写服务 Windows service
    C# 调用FFmpeg 根据图片合成视频
    Socket 编程示例(二)
  • 原文地址:https://www.cnblogs.com/Yirson/p/5910308.html
Copyright © 2020-2023  润新知