我被赋予了使用datepicker,ajax,php和mysql在两个给定日期之间生成报告的任务.以下是我的html:
日期明智的报告
From date: To date:
脚本:
$(function() {
$( "#fromdate" ).datepicker();
$( "#todate" ).datepicker();
});
function showUser(fromdate,todate)
{
if (fromdate =="" && todate=="")
{
document.getElementById("txtHint").innerHTML="";
return;
}
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
document.getElementById("txtHint").innerHTML=xmlhttp.responseText;
}
}
xmlhttp.open("GET","bet_date.php?fromdate="+fromdate+"&todate="+todate,true);
xmlhttp.send();
}
这是应该生成报告的php文件:
bet_date.php
include("database.php");
$fromdate=$_GET["fromdate"];
$todate=$_GET["todate"];
$sql = "SELECT * FROM bookings WHERE date between '$fromdate' and '$todate'";
$result = mysql_query($sql);
echo "
id | date | start | name | phone | comments | approved |
---|
while($row = mysql_fetch_array($result))
{
echo "
";echo "
" . $row['id'] . "";echo "
" . $row['date'] . "";echo "
" . $row['start'] . "";echo "
" . $row['name'] . "";echo "
" . $row['email'] . "";echo "
" . $row['phone'] . "";echo "
" . $row['comments'] . "";echo "
" . $row['approved'] . "";echo "
";}
echo "
";问题是当我同时选择两个日期时什么也没发生.
在这种情况下,请帮我.
简单的例子将不胜感激.
谢谢.