我一直从我的 jquery 获取值并将其传递给我的 PHP。我得到了正确的值,问题是我的 highchart 没有使用我从 jQuery 获得的值显示数据。这是我的脚本。
<?php
include ('connect.php');
$years = array(2011=>'Select year','2012','2013','2014','2015','2016','2017','2018','2019','2020','2021','2022','2023','2024','2025','2026','2027','2028','2029','2030');
$year_count= count($years);
$year = $year_count + 2010;
?>
<script>
$(document).ready(function()
{
$("#years").change(function(event)
{
var y=$(this).val();
if(y!='2011' || y!='NULL')
{
alert(y);
$("#memcount").load('reports/yearly_sales.php', {"y":y});
$("#top10").load('reports/yearly_customers.php', {"y":y});
}
});
});
Year: <select id="years">
<?php
for($yr=2011; $yr<=$year; $yr++)
{
echo "<option value='".$yr."'>".$years[$yr]."</option>";
}
?>
这是我的 php
<?php
if(isset($_POST['y']))
{
$y = $_POST['y'];
?>
<div id='top10' style='width: 680px; height: 400px; margin: 0 auto'></div>
<?php
$months = array();
$jan_tot = 0;
$feb_tot = 0;
//jan
$jan = mysql_query("SELECT count(customer_id) AS count_id, date_added FROM `customer` WHERE date_added LIKE '$y-01-%'");
while($janfetch = mysql_fetch_array($jan))
{
$jan_tot=(int)$janfetch['count_id'];
}
//feb
$feb = mysql_query("SELECT count(customer_id) AS count_id FROM `customer` WHERE date_added LIKE '$y-02-%'");
while($febfetch = mysql_fetch_array($feb))
{
$feb_tot=(int)$febfetch['count_id'];
}
}
?>
感谢那些会帮助我的人。我非常需要这个。