这里是脚本如果我选择日期然后我从数据库中获取数据。但如果我选择任何日期,那么我无法从数据库中获取从日历中选择日期的任何数据。有人能修好吗?
<script language="JavaScript" type="text/javascript" src="calendar/calendar.js"></script>
<script src="jquery.js"></script>
<script>
$(document).ready(function()
{
//ajaxTime.php is called every second to get time from server
var refreshId = setInterval(function()
{
$('#timeval').load('ajaxTime.php?randval='+ Math.random());
}, 1000);
//stop the clock when this button is clicked
$("#stop").click(function()
{
clearInterval(refreshId);
});
});
</script>
<!--<strong><div align="right" id="timeval" style="color:#FF6600; font-family:Arial, Helvetica, sans-serif">--:--:--</div></strong>-->
<table width="420" border="1" >
<form name="showdraw" action="ooo.php" method="post">
<tr bgcolor="#FF6600">
<td><script> DateInput('cdate', true, 'YYYY-MM-DD'); </script></td>
<td> <input type="submit" value ="Show"> <input type="hidden" value="Show" name="d1"> </td>
</tr>
<tr bgcolor="#FF6600">
<td><font color=#2F4F4F><h2>Draw Time</h2></font></td>
<td><font color=#2F4F4F><h2>Wining Number</h2></font></td>
</tr>
</form>
<tbody>
<?php
include('connect.php');
if (isset($_GET["d1"])) { $d1= $_GET["d1"]; } else { $d1=('YYYY-MM-DD'); };
$result = $db->prepare("SELECT * FROM birthday WHERE date = :a");
$result->bindParam(':a', $d1);
$result->execute();
for($i=0; $row = $result->fetch(); $i++){
?>
<tr class="record">
<tr bgcolor="#EEF3E2">
<td><font size=5><font color='#008B00'><?php echo $row['dt']; ?></font></td>
<td><font size=5><font color='#008B00'><?php echo $row['wn']; ?></font></td>
<?php
}
?>
</tbody>
</table>
答案 0 :(得分:0)
好的,从表单标记开始,这里有很大一部分代码。我不知道为什么你继续把这个隐藏的输入。如果日历输入名为d1,则不需要它。如果添加具有相同名称的第二个输入,则将消除正确的值,并且您永远不会从日历输入中获取日期。
<form name="showdraw" action="ooo.php" method="post">
<tr bgcolor="#FF6600">
<td><script> DateInput('cdate', true, 'YYYY-MM-DD'); </script></td>
<td> <input type="submit" value ="Show"> </td>
</tr>
<tr bgcolor="#FF6600">
<td><font color="#2F4F4F"><h2>Draw Time</h2></font></td>
<td><font color="#2F4F4F"><h2>Wining Number</h2></font></td>
</tr>
</form>
<tbody>
<?php
include('connect.php');
if (isset($_GET["d1"])) {
$d1= $_GET["d1"];
} else {
$d1=date('YYYY-MM-DD');
}
$result = $db->prepare("SELECT * FROM birthday WHERE date = :a");
$result->bindParam(':a', $d1);
$result->execute();
while($row = $result->fetchAll()){
?>
<tr class="record">
<tr bgcolor="#EEF3E2">
<td><font size="5"><font color="#008B00"><?php echo $row['dt']; ?></font></td>
<td><font size="5"><font color="#008B00"><?php echo $row['wn']; ?></font></td>
</tr>
<?php } ?>
</tbody>
</table>