gpt4 book ai didi

PHP SQL 上一个和下一个日期导航

转载 作者:行者123 更新时间:2023-11-30 00:35:09 24 4
gpt4 key购买 nike

我有这个代码,用于显示当天的比赛

<?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>";
}
?>

我想要的是前一天和后一天的 2 个按钮,可以进入查询并检索该日期的数据,这些按钮可以多次单击,而不仅仅是一次

最佳答案

试试这个

<?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>

关于PHP SQL 上一个和下一个日期导航,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22241635/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com