我有这段 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>";
}
}
此代码从数据库检索数据并将其显示在 HTML 表中。除日期外,所有内容都会显示。不过,当我在 MySQL 命令行中运行查询时,它工作正常,并且也以所需的格式显示日期。唯一不显示的地方是 HTML 表格中。我需要知道我做错了什么。以下是分别在 HTML 表和 SQL 表中的表输出:
四季花海
相关分类