我有這段 HTML 代碼:if($_GET["disp"]){ include 'config.php'; $searchstr=$_GET['cname']; $sql="select cname, date_format(podate, '%d-%m-%Y'), started, reason, date_format(tentdate, '%d-%m-%Y'), progress, status from info where cname='$searchstr';"; $result=mysqli_query($conn, $sql); if($searchstr==""){ $message="Please enter a customer name"; echo "<script type='text/javascript'>alert('$message'); window.location.href='retreive.php';</script>";}else{ echo "<table id='info' border='1px solid black'><tr padding='2'><th>Customer Name</th><th>Purchase Order Date</th><th>Started?</th><th>Reason (If any)</th><th>Tentative start date</th><th>Progress</th><th>Current Status</th><th>New status</th></tr>"; while ($row = $result->fetch_assoc()) { $cname=$row['cname']; $podate=$row['podate']; $started=$row['started']; $reason=$row['reason']; $tentdate=$row['tentdate']; $progress=$row['progress']; $status=$row['status']; echo "<tr><td>".$cname."</td><td>".$podate."</td><td>".$started."</td><td>".$reason."</td><td>".$tentdate."</td><td>".$progress."</td><td>".$status."</td><td><select id='status' name='status'> <option value='L1 Ongoing'>L1 Ongoing</option> <option value='L1 Complete'>L1 Complete</option> <option value='L2 Ongoing'>L2 Ongoing</option> <option value='L2 Complete'>L2 Complete</option> <option value='Invoice'>Invoice</option></select></td></tr>"; } echo "</table><br>";}}此代碼從數(shù)據(jù)庫檢索數(shù)據(jù)并將其顯示在 HTML 表中。除日期外,所有內(nèi)容都會(huì)顯示。不過,當(dāng)我在 MySQL 命令行中運(yùn)行查詢時(shí),它工作正常,并且也以所需的格式顯示日期。唯一不顯示的地方是 HTML 表格中。我需要知道我做錯(cuò)了什么。以下是分別在 HTML 表和 SQL 表中的表輸出:html表 sql表
1 回答

四季花海
TA貢獻(xiàn)1811條經(jīng)驗(yàn) 獲得超5個(gè)贊
您正在使用date_format
該列上的函數(shù)。
結(jié)果鍵將被稱為類似但您正在代碼中date_format(podate, '%d-%m-%Y')
檢查的名稱。podate
給它一個(gè)別名podate
,一切都很好。
例如
... date_format(podate, '%d-%m-%Y') AS podate ....
- 1 回答
- 0 關(guān)注
- 183 瀏覽
添加回答
舉報(bào)
0/150
提交
取消