0
我有一個圖表顯示了一個人預訂的展位總數,但是我想顯示該人在一週中的某一天預訂的展位數量。如何在圖表中顯示每週的每週數據?
下面是我的代碼,顯示了總預訂:
<?php
$current_day = date("N");
$days_to_sat = 6 - $current_day;
$days_from_sun = $current_day - 0;
$monday = date("d-m-y", strtotime("- {$days_from_sun} Days"));
$friday = date("d-m-y", strtotime("+ {$days_to_sat} Days"));
echo $monday." To ".$friday;
$c=$_SESSION['user'];
$sth =mysql_query("SELECT count(`booth_number`) AS 'booth',`sold_by` FROM `registration1` where week(`Date`) = week(curdate()) and where `sold_by`= '$c' ");
$rows = array();
$flag = true;
$table = array();
$table['cols'] = array(
array('label' => 'sold_by', 'type' => 'string'),
array('label' => 'booth', 'type' => 'number')
);
$rows = array();
while($r = mysql_fetch_assoc($sth)) {
$temp = array();
$temp[] = array('v' => (string) $r['sold_by']);
$temp[] = array('v' => (int) $r['booth']);
$rows[] = array('c' => $temp);
}
$table['rows'] = $rows;
$jsonTable = json_encode($table);
?>
<!--Load the Ajax API-->
<script type="text/javascript" src="https://www.google.com/jsapi"></script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
<script type="text/javascript">
// Load the Visualization API and the piechart package.
google.load('visualization', '1', {'packages':['corechart']});
// Set a callback to run when the Google Visualization API is loaded.
google.setOnLoadCallback(drawChart);
function drawChart() {
// Create our data table out of JSON data loaded from server.
var data = new google.visualization.DataTable(<?=$jsonTable?>);
var options = {
title:" Total Booth Booked ",
width: 400, height: 200,
minorTicks: 5
};
// Instantiate and draw our chart, passing in some options.
// Do not forget to check your div ID
var chart = new google.visualization.BarChart(document.getElementById('chart_div'));
chart.draw(data, options);
}
</script>
<!--this is the div that will hold the pie chart-->
<div id="chart_div"></div>
任何機構那裏幫助我在這 – mamtasingla