PeterM 帮我解决了这个问题,但我不想创建新的,这就是我编辑这个问题的原因。我遇到了另一个问题,抱歉,我刚接触 sql。
这是我的代码,它从数据库中输出我需要的所有信息。我想要什么:我创建了名为“customers”的表,其中包含“id 和 customername”列。然后我用 INSERT INTO "customers" 创建了简单的脚本,是的,它的脚本就像管理页面。这个想法是:我想从一个单独的页面添加新订单,例如:admin.php,所以我不必从文件中添加。如何轻松做到这一点?我有 admin.php 文件: INSERT INTO customers (customername) VALUES (customername) 及其工作,我可以向数据库添加新订单,当我填写 html 表单时,它不会显示我新添加的订单。
<?php
$output = "SELECT *, SUM(enddate - startdate) AS time FROM employees GROUP
BY id";
$result = mysqli_query($conn, $output);
WHILE ($row = mysqli_fetch_assoc($result)) {
$EMPLOYEE = $row['employee'];
$CUSTOMER = $row['customername'];
$WORKDATE = $row['workdate'];
$WORKTYPE = $row['worktype'];
$DAYHOURS = $row['startdate'];
$ENDDATE = $row['enddate'];
$TOTAL = $row['time'];
echo "
<tr>
<td>$EMPLOYEE</td>
<td>$CUSTOMER</td>
<td>$WORKDATE</td>
<td>$WORKTYPE</td>
<td>$DAYHOURS</td>
<td>$ENDDATE</td>
<td>$TOTAL</td>
</tr>";
}
?>
我的 html 表单:
<div class='row'>
<div class='col-25'>
<label for='customers'>Choose OrderName</label>
</div>
<div class='col-75'>
<select name='customername'>
<?php
$customers = "SELECT customername FROM customers";
$result = mysqli_query($conn, $customers);
WHILE ($row = mysqli_fetch_assoc($result)) {
$customer = $row['customername'];
echo "<option value=''>$customer</option>";
}
?>
</select>
</div>
</div>
人到中年有点甜