PHP SQL上一个和下一个日期导航
我有这个代码,我用它来显示当天的匹配PHP SQL上一个和下一个日期导航,php,mysql,sql,Php,Mysql,Sql,我有这个代码,我用它来显示当天的匹配 <?php $today = date('Y-m-d'); $data = mysql_query("SELECT * FROM todaysmatches where matchdate=$today") or die(mysql_error()); echo "<h4>$today Matches</h4> </br>"; //table if(mysql_num_rows($data)==0){
<?php
$today = date('Y-m-d');
$data = mysql_query("SELECT * FROM todaysmatches where matchdate=$today") or die(mysql_error());
echo "<h4>$today Matches</h4> </br>";
//table
if(mysql_num_rows($data)==0){
echo " No Matches";
}else{
echo "<table border='1'>
<tr>
<th>Match</th>
<th>Tourmanet</th>
<th>Date</th>
</tr>";
while($info = mysql_fetch_array( $data )){
echo "<tr>";
echo "<td>" . $info['curmatch'] . "</td>";
echo "<td>" . $info['tournamentname'] . "</td>";
echo "<td>" . $info['matchdate'] . "</td>";
echo "</tr>";
}
echo "</table>";
}
?>
我想得到的是前一天和第二天的两个按钮,可以进入查询并检索该日期的数据,这些按钮可以被多次单击,而不仅仅是那些按钮
<?php
//$today = date('Y-m-d');
$firstdate = $_POST['firstdate']; // first date which is today
$seconddate = $_POST['seconddate']; //or make this some date you want
//if submit button is pressed do this
if(isset($_POST['submit'])){
$data = mysql_query("SELECT * FROM todaysmatches where matchdate=$today")
or die(mysql_error());
echo "<h4>$today Matches</h4> </br>";
//table
if (empty($data)){
echo " No Matches";
}
else{
echo "<table border='1'>
<tr>
<th>Match</th>
<th>Tourmanet</th>
<th>Date</th>
</tr>";
while($info = mysql_fetch_array( $data ))
{
echo "<tr>";
echo "<td>" . $info['curmatch'] . "</td>";
echo "<td>" . $info['tournamentname'] . "</td>";
echo "<td>" . $info['matchdate'] . "</td>";
echo "</tr>";
}
echo "</table>";
}
}//end submit button press
?>
<form action="" method="POST">
<input type="hidden" name="firstdate" value="<?php echo date('Y-m-d'); ?>"/>
<input type="submit" name="submit" value="submit" />
</form>
<form action="" method="POST">
<input type="hidden" name="seconddate" value=""/>
<input type="submit" name="submit" value="submit" />
</form>
你试过什么?你被卡在哪里了?你不应该只是要求我们为你做这件事,你需要表明你已经做了一些努力来完成它。我尝试了一个日期选择器,我认为它更易于使用和导航,但我无法获得输入并在查询中使用它这是我使用的日期选择器http://jqueryui.com/datepicker/#event-onSelect