无法在 php 的 mysql 数据库的饼图中显示值

Unable to show value in piechart from mysql database in php

我想绘制一个饼图,其中的值将从 MySQL 数据库中获取。但它不起作用。但如果我给出手动值,则会显示饼图。下面是我的代码:

<?php
include "libchart/classes/libchart.php";

header("Content-type: image/png");

$chart = new PieChart(500, 260);
$con=mysqli_connect("localhost","root","","bkash");
// Check connection
if (mysqli_connect_errno())
{
    echo "Failed to connect to MySQL: " . mysqli_connect_error();
}

$result = mysqli_query($con,"SELECT count(*) FROM dialer_rate where mno='tnr' and success=1 ");
$result1 = mysqli_query($con,"SELECT count(*) FROM dialer_rate where mno='tnr' and failed=1");
$dataSet = new XYDataSet();
$dataSet->addPoint(new Point("Success", $result));
$dataSet->addPoint(new Point("Failed", $result1));
#$dataSet->addPoint(new Point(" (50)", 50));
$chart->setDataSet($dataSet);

$chart->setTitle("bKash USSD Dialer Success/Fail rate");
$chart->render();
?>

但是,如果我在下面的两个字段中给出手动值,那么它就可以工作了。任何人都请帮助。

$dataSet->addPoint(new Point("Success", 20));
$dataSet->addPoint(new Point("Failed", 80));

试试这个

...
$result = mysqli_query($con,"SELECT count(*) as count FROM dialer_rate where mno='tnr' and success=1 ");
$result1 = mysqli_query($con,"SELECT count(*) as count1 FROM dialer_rate where mno='tnr' and failed=1");
$result = $result->fetch_object();
$result1 = $result1->fetch_object();
$dataSet = new XYDataSet();
$dataSet->addPoint(new Point("Success", $result->count));
$dataSet->addPoint(new Point("Failed", $result1->count1));
...