<%
lg_time_end = getStr(request.getParameter("lg_time_end"));
lg_time_start = getStr(request.getParameter("lg_time_start"));
lg_st = getStr(request.getParameter("lg_st"));
lg_kiln = getStr(request.getParameter("lg_kiln"));

ResultSet rs=null;
query = "select * from f301a_lg where lg_time <= '" + lg_time_end + "' and lg_time >= '" + lg_time_start + "' and lg_st like '%" + lg_st + "%'and lg_kiln like '%" + lg_kiln + "%'"; rs = Pagi.querySql(query, request);
WebChart dataset = new WebChart();
while (rs.next()) 

dataset.addValue(rs.getDouble("lg_htem"), "测温区域", rs.getString("lg_st"));
/*dataset.addValue(rs.getDouble("lg_atem"), "测温区域", rs.getString("lg_htem"));*/

             //d1.push([i, Math.sin(i)]);

} //out.println(r_permission);
rs.close();
Pagi.closeConn();String filename1 = dataset.generateLineChart("红外测试数据","测温区域","温度" ,session, new PrintWriter(out),true);
String graphURL1 = request.getContextPath() + "/DisplayChart?filename=" + filename1;
%><P ALIGN="CENTER">
<img src="<%= graphURL1 %>" width=1000 height=600 border=0 usemap="#<%= filename1 %>">
</P>
    
    
以上是jsp代码,可以完成oracle数据库的查询和作图功能,但是对结果不是满意,在网上找了一个plot的php组建,发现效果不错,但是php查询代码我不会写,希望大侠给我帮助。贴出php模板代码:    
    <div id="placeholder" style="width:600px;height:300px;"></div><script id="source" language="javascript" type="text/javascript">
$(function () {

    var d1 = [];
    for (var i = 0; i < 14; i += 0.5)
        d1.push([i, Math.sin(i)]);    var d2 = [[0, 3], [4, 8], [8, 5], [9, 13]];    // a null signifies separate line segments
    var d3 = [[0, 12], [7, 12], null, [7, 2.5], [12, 2.5]];
    
    $.plot($("#placeholder"), [ d1, d2, d3 ]);
});
</script>
我现在要的就是在php中用类似jsp中的select查询,将lg_htem、lg_st存入数组中,就可以作出图了。
拜谢大侠们了。

解决方案 »

  1.   

    给你一个PHP执行数据库查询的例子,摘自PHP手册:
    http://www.php.net/manual/en/function.mysql-query.php
    <?php
    // This could be supplied by a user, for example
    $firstname = 'fred';
    $lastname  = 'fox';// Formulate Query
    // This is the best way to perform an SQL query
    // For more examples, see mysql_real_escape_string()
    $query = sprintf("SELECT firstname, lastname, address, age FROM friends WHERE firstname='%s' AND lastname='%s'",
        mysql_real_escape_string($firstname),
        mysql_real_escape_string($lastname));// Perform Query
    $result = mysql_query($query);// Check result
    // This shows the actual query sent to MySQL, and the error. Useful for debugging.
    if (!$result) {
        $message  = 'Invalid query: ' . mysql_error() . "\n";
        $message .= 'Whole query: ' . $query;
        die($message);
    }// Use result
    // Attempting to print $result won't allow access to information in the resource
    // One of the mysql result functions must be used
    // See also mysql_result(), mysql_fetch_array(), mysql_fetch_row(), etc.
    while ($row = mysql_fetch_assoc($result)) {
        echo $row['firstname'];
        echo $row['lastname'];
        echo $row['address'];
        echo $row['age'];
    }// Free the resources associated with the result set
    // This is done automatically at the end of the script
    mysql_free_result($result);
    ?>
      

  2.   

    请问如何将$query = sprintf("SELECT firstname, lastname, address, age FROM friends WHERE firstname='%s' AND lastname='%s'",
        mysql_real_escape_string($firstname),
        mysql_real_escape_string($lastname));查出的数据,例如lastname,age存放到var d1[]数组中?不胜感激啊
      

  3.   

    类似下面的:
    $i = 0;
    while ($row = mysql_fetch_assoc($result)) {
        $d1[$i]['firstname'] = $row['firstname'];
        $d1[$i]['lastname'] = $row['lastname'];
        $i++;
    }