+------------------+
| Tables_employees |
+------------------+
| empid |
| aid |
| FirstName |
| LastName |
| Email |
| Phone |
<table id="exampleC" class="display" cellpadding="1" cellspacing="1" width="" style="font-size:small;">
<thead>
<tr>
<th>1st Name</th>
<th>2nd Name</th>
<th>Title</th>
<th>Email</th>
<th>Phone(D)</th>
<th>Linkedin</th>
</tr>
</thead>
<tbody>
<?php
require_once 'tabconnect.php';
if (isset($_GET['id'])) {
$id = $_GET['id'];
$data = mysqli_query($connection,"SELECT acquisition.aid,acquisition.aby,employees.empid,employees.aid,employees.FirstName,employees.LastName,employees.title,employees.email,employees.phone,employees.dphone,employees.LIUrl,employees.listatus FROM employees JOIN acquisition ON acquisition.aid=employees.aid where acquisition.aid=$id");
while ($row3 = mysqli_fetch_array($data)) { ?>
<tr>
<td><?php echo $row3['FirstName']; </td>
<td><?php echo $row3['LastName']; ?</td>
<td><?php echo $row3['title']; ?></td>
<td><a class="" href="<?php echo $row3['email']; ?>" target="_blank"><i class="icon-custom icon-sm rounded-x fa fa fa-envelope"></i></td>
<td><a class="" href="<?php echo $row3['phone']; ?>" target="_blank"><i class="icon-custom icon-sm rounded-x fa fa-phone"></i></td>
</tr>
<?php
}
}
?>
</tbody>
</table>
问题是它会显示所有电子邮件和电话图像,但我只想在表中有记录时才显示图像
最佳答案
不清楚您是要填写所有记录还是只填写有图标的记录,您可以检查如下字段:
<?php
while ($row3 = mysqli_fetch_array($data)) {
?>
<tr>
<td><a class="" href="<?php echo ($row3['email'])?$row3['email']:''; ?>" target="_blank">
<?php if($row3['email']!=''){ echo '<i class="icon-custom icon-sm rounded-x fa fa fa-envelope"></i>';
}else{echo '';} ?></td>
<td><a class="" href="<?php echo ($row3['phone'])?$row3['phone']:''; ?>" target="_blank">
<?php if($row3['email']!=''){ echo '<i class="icon-custom icon-sm rounded-x fa fa-phone"></i>'; }
else{echo '';}</td>
</tr>
<?php
}
?>
关于php - 不要在 php 中显示 mysql 表中的空结果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45996035/