使用PHP MYSQL的Jquery flot pie

时间:2022-12-03 17:10:02

I have some problems. Excuse me for my english.

我有一些问题。对不起我的英语。

I'ld display the datas but nothing !!

我显示数据但没有!

I dont know where is the probleme. I dont find it. Thnaks you for your help.

我不知道问题出在哪里。我找不到它。向你致以帮助。

code html

<div id="pie2" style="height:300px"></div>

code javascript

jQuery(document).ready(function ($){
var options = {
        series: {
            pie: { 
                show: true,
                radius: 1,
                    label: {
                        show: true,
                        radius: 2 / 3,
                        tilt:0.5,
                        formatter: function(label, series) 
                        {
                            return '<div style="font-size:8pt;text-align:center;padding:2px;color:white;">' + label + '<br/>' + Math.round(series.percent) + '% (' + series.data[0][1] + ')</div>';
                        },

                        background: 
                        {
                            opacity: 0.8
                        }
                    }
            }
        },
        legend: {
            show: true
        }
    };
var dataset1 = <?php echo json_encode($pie);?>;
var data = [
            {
                "label": "Random Values",
                "data": dataset1
            }
        ]; 
var plotarea = $("#pie2");
$.plot( plotarea , data);

});

code PHP (source_pie.php)

代码PHP(source_pie.php)

$sql = "SELECT COUNT(rne) AS rne, dept FROM anuetab GROUP BY dept";
$result = mysql_query($sql);
while($row = mysql_fetch_assoc($sql)){
$pie[] = array(
    'label'=>$row['dept'],
    'data'=>$row['rne']
    );
echo '<pre>';
print_r($pie);
echo '</pre>';
}
echo json_encode($pie);

1 个解决方案

#1


0  

try with mysql_fetch_row instead of mysql_fetch_assoc

尝试使用mysql_fetch_row而不是mysql_fetch_assoc

#1


0  

try with mysql_fetch_row instead of mysql_fetch_assoc

尝试使用mysql_fetch_row而不是mysql_fetch_assoc