gpt4 book ai didi

php - 如何使用 mysql 和 php 获取 future 3 个月的结果

转载 作者:行者123 更新时间:2023-11-30 00:58:41 26 4
gpt4 key购买 nike

这显示了当月结果

我想要接下来 3 个月的结果,我该怎么做请帮我解决这个问题

谢谢

代码

  $result = mysql_query("SELECT * FROM register where 
EXTRACT(YEAR_MONTH FROM `agreementdatee`) =
EXTRACT(YEAR_MONTH FROM CURRENT_DATE)
ORDER BY CAST(flatno as SIGNED INTEGER)
DESC LIMIT 4");

完整代码

 <?php
$username = "root";
$password = "";
$hostname = "localhost";

//connection to the database
$dbhandle = mysql_connect($hostname, $username, $password)
or die("Unable to connect to MySQL");
echo "<br>";

//select a database to work with
$selected = mysql_select_db("building",$dbhandle)
or die("Could not select examples");


//execute the SQL query and return records
$result = mysql_query("SELECT * FROM register where
EXTRACT(YEAR_MONTH FROM `agreementdatee`) =
EXTRACT(YEAR_MONTH FROM CURRENT_DATE)
ORDER BY CAST(flatno as SIGNED INTEGER)
DESC LIMIT 4");

//fetch tha data from the database
while ($row = mysql_fetch_array($result)) {
echo "Date: ".$row{'agreementdatee'}." Name : ".$row{'buildingname'}." Flat No: ". //display the results
$row{'flatno'}."<br>";
}
//close the connection
mysql_close($dbhandle);
?>

最佳答案

 $result = mysql_query("SELECT * FROM register where 
agreementdatee BETWEEN NOW() AND DATE_ADD(NOW(), INTERVAL 3 MONTH)
ORDER BY CAST(flatno as SIGNED INTEGER)
DESC LIMIT 4");

这将选择协议(protocol)日期 >= 现在且之前或等于 future 3 个月的所有内容

关于php - 如何使用 mysql 和 php 获取 future 3 个月的结果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20332338/

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