问:我有一个表格和MSSQL DB,其中列出了一个财政年度中任何日期的期间和星期开始日期,但是该页面仅显示周号和期间号,没有日期请问任何机构没有任何想法。
<?php
$serverName = 'DESKTOP-R7RU80H\SQLEXPRESS';
$connectionInfo=array('Database'=>'WebPortal', 'UID'=>'WebAdmin', 'PWD'=>'P455w0rd');
$conn = sqlsrv_connect($serverName, $connectionInfo);
if ($conn ) {
/*
echo "Connection established.";
*/
}else{
echo "Connection could not be established.";
die( print_r( sqlsrv_errors(), true));
}
echo $Today = date("Y-m-d");
echo "</br> </br>";
$sql = "SELECT * FROM Calendar_Data WHERE Date = '$Today'";
$result = sqlsrv_query($conn, $sql);
while($rowvar = sqlsrv_fetch_array($result))
{
$Financial_Year = ($rowvar['Financial_Year']);
$Period = ($rowvar['Period']);
$Week = ($rowvar['Week']);
$FY_Start_Date = ($row['FY_Start_Date']);
$FY_End_Date = ($row['FY_End_Date']);
$Week_Start_Date = ($row['Week_Start_Date']);
$Week_End_Date = ($row['Week_End_Date']);
$Period_Start_Date = ($row['Period_Start_Date']);
$Period_End_Date = ($row['Period_End_Date']);
}
echo $rowvar;
echo "Today's Date is ";
echo $Today;
echo "</br> </br>This Week's Start Date is ";
echo $Week_Start_Date;
echo "</br> </br>This Period's Start Date is ";
echo $Period_End_Date;
?>
答:数据库中的数据是什么样的?您的代码的第20行正在检索今天日期的Calendar_Data表行中的所有数据。