【发布时间】:2018-06-27 10:47:59
【问题描述】:
我有这张休假表格,员工可以在其中申请休假。一切正常,唯一的问题是我无法显示待处理状态。我已经在我的桌子上定义了status 的默认值。
这是我查看树叶时的样子:
这是我的表结构:
我不确定你们是否需要我的查看离开代码,但这里是:
<div class="table-responsive">
<table class="table">
<tr>
<th>Employee Name</th>
<th>Phone</th>
<th>Email</th>
<th>From</th>
<th>To</th>
<th>Reason</th>
<th>Status</th>
</tr>
<?php
include ('database.php');
$result = $database->prepare ("SELECT * FROM leaves order by id DESC");
$result ->execute();
for ($count=0; $row_message = $result ->fetch(); $count++){
?>
<tr>
<td><?php echo $row_message['full_name']; ?></td>
<td><?php echo $row_message['phone']; ?></td>
<td><?php echo $row_message['email']; ?></td>
<td><?php echo $row_message['fromdate']; ?></td>
<td><?php echo $row_message['todate']; ?></td>
<td><?php echo $row_message['reason']; ?></td>
<td><?php echo $row_message['status']; ?></td>
</tr>
<?php } ?>
</table>
<a href="home"><button type="button" class="btn btn-primary"><i class="glyphicon glyphicon-arrow-left"></i> Back</button></a>
</div>
</div>
【问题讨论】:
-
请不要包含指向表结构等的链接。请将它们实际粘贴到问题中。
-
@MatBailie 喜欢粘贴图片吗?我认为只有 10 次以上的代表才能做到这一点。
-
您似乎插入了数据并且然后应用了默认值? 或者你特意插入了
NULL或者空字符串?仅当您不提供值时,才会在INSERTand 期间使用默认值。例如,如果一个表有字段a, b, c并且c有一个默认值,您可以使用:INSERT INTO table (a, b) VALUES (1, 2)。如果您给c一个值,无论是NULL还是一个空字符串,都不会应用默认值。在SELECT期间肯定不会应用它。这意味着您必须UPDATE这些行。 -
无论如何你都应该很少使用图片。使用文字。
-
尝试另一个插入,将状态字段留空
标签: php html sql database phpmyadmin