0

我正在尝试从 mysql 数据中检索数据并将其显示在运行会话的 PHP 页面中。代码在单独的页面中运行。并且数据在另一个页面中被检索为图像。主要问题是无论我在默认的图形编码之上放置什么样的编码,它都会变成一个破碎的图像。仅供参考,我已经启用了 php_gd2.dll,并且我的 php.ini 文件中的扩展名设置为扩展文件夹。是否必须在任何文件中进行任何其他修复?

<?php
session_start();

if($_SESSION['username'])
{
require "dbc.php";  
echo "<h2>Patient Glucose Data</h2>";

$username = $_SESSION['username'];
$query_view = mysql_query("SELECT * FROM user_glucose WHERE username='$username'");

$numrows = mysql_num_rows($query_view);

    if ($numrows != 0)
    {
        while ($rows = mysql_fetch_assoc($query_view))
        {

        $print_day1  = $rows['Day1'];
        $print_day2  = $rows['Day2'];
        $print_day3  = $rows['Day3'];
        $print_day4  = $rows['Day4'];
        $print_day5  = $rows['Day5'];
        $print_day6  = $rows['Day6'];
        $print_day7  = $rows['Day7'];
        $print_day8  = $rows['Day8'];
        $print_day9  = $rows['Day9'];
        $print_day10 = $rows['Day10'];
        $print_day11 = $rows['Day11'];
        $print_day12 = $rows['Day12'];
        $print_day13 = $rows['Day13'];
        $print_day14 = $rows['Day14'];


        }

    }
    require('/jpgraph-3.5.0b1/src/jpgraph.php');
    require('/jpgraph-3.5.0b1/src/jpgraph_line.php'); 

    //  data
    $ydata =       
array($print_day1,$print_day2,$print_day3,$print_day4,$print_day5,$print_day6,$print_day7,$print_day8,$print_day9);

// Create the graph. These two calls are always required
$graph = new Graph(500,500);
$graph->SetScale('textlin');
$graph->xaxis->title->Set("Number of Days");
$graph->yaxis->title->Set("Glucose Concentration");

// Create the linear plot
$lineplot=new LinePlot($ydata);
$lineplot->SetColor('blue');

// Add the plot to the graph
$graph->Add($lineplot);

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

 }
 ?>
4

0 回答 0