通过php从mysql返回空值
我正在做一个项目,我需要通过电子邮件发送两个警报。我已经实现了一个电子邮件警报,其工作正常,在成功发送电子邮件后,我将收到状态消息“已完成”,但对于第二个警报,我又添加了一列“服务状态”。虽然电子邮件功能工作正常,但它不显示completed,而是显示null或空值,但数据库中的值是“completed”。。。这是我的代码表,我需要显示完成的结果通过php从mysql返回空值,php,mysql,codeigniter,Php,Mysql,Codeigniter,我正在做一个项目,我需要通过电子邮件发送两个警报。我已经实现了一个电子邮件警报,其工作正常,在成功发送电子邮件后,我将收到状态消息“已完成”,但对于第二个警报,我又添加了一列“服务状态”。虽然电子邮件功能工作正常,但它不显示completed,而是显示null或空值,但数据库中的值是“completed”。。。这是我的代码表,我需要显示完成的结果 <?php if(count($det)){ ?> <?php for($i=0;$i<count($det);$i+
<?php
if(count($det)){
?>
<?php for($i=0;$i<count($det);$i++)
{?>
<tr class="rowvalues">
<td rowspan="2" class="bottomcolor">
<input type="checkbox" name="list[]" value="<?php echo $det[$i]['customer_id']; ?>" /></td>
<td rowspan="2" class="bottomcolor"><?php echo $det[$i]['customer_title'].".".$det[$i]['customer_surname']; ?></td>
<td rowspan="2" class="bottomcolor"><?php echo $det[$i]['vehicle_regno']; ?></td>
<td>Reminder1</td>
<td><?php
if ($det[$i]['reminder1_duedate'] != '0000-00-00'){
echo date('d/m/Y',strtotime($det[$i]['reminder1_duedate']));}else{echo '00/00/0000';} ?></td>
<td><?php if ($det[$i]['reminder1_duedate'] != '0000-00-00'){ echo date('d/m/Y',strtotime($det[$i]['reminder1_duedate'].'- 28 days'));}else{echo '00/00/0000';} ?></td>
<td><?php if ($det[$i]['reminder1_duedate'] != '0000-00-00'){ echo date('d/m/Y',strtotime($det[$i]['reminder1_duedate'].'- 14 days'));}else{echo '00/00/0000';} ?></td>
<td><?php if ($det[$i]['reminder1_duedate'] != '0000-00-00'){ echo date('d/m/Y',strtotime($det[$i]['reminder1_duedate'].'- 2 days'));}else{echo '00/00/0000';} ?></td>
<td><?php echo isset($det[$i]['reminder1_status'])?($det[$i]['status']=='c')?'Completed':'Pending':'';?> </td>
<td rowspan="2" class="bottomcolor"><a href="<?php echo base_url();?>preview/view_vehicle.php?vid=<?php echo $det[$i]['customer_id'];?>" rel="facebox"><img src="<?php echo base_url();?>images/view.gif" alt="View"/></a>
<a style="text-decoration:none;" href="<?php echo base_url();?>index.php/vehicles/edit_mot/<?php echo $det[$i]['customer_id'];?>" title="Edit"> <img src="<?php echo base_url();?>images/edit.gif" alt="search"/></a> <a style="text-decoration:none;" href="<?php echo base_url();?>index.php/vehicles/view/delete/<?php echo $det[$i]['customer_id'];?>" onclick="return confirm('Are you sure you want to delete this Vehicle Details?');" title="Delete">
<img src="<?php echo base_url();?>images/delete.gif" alt="delete"/></a></td>
</tr>
<tr>
<td class="bottomcolor">Reminder 2</td>
<td class="bottomcolor"><?php
if ($det[$i]['reminder2_duedate'] != '0000-00-00'){
echo date('d/m/Y',strtotime($det[$i]['reminder2_duedate'])); }else{echo '00/00/0000';}?></td>
<td class="bottomcolor"><?php if ($det[$i]['reminder2_duedate'] != '0000-00-00'){ echo date('d/m/Y',strtotime($det[$i]['reminder2_duedate'].'- 28 days'));}else{echo '00/00/0000';}?></td>
<td class="bottomcolor"><?php if ($det[$i]['reminder2_duedate'] != '0000-00-00'){ echo date('d/m/Y',strtotime($det[$i]['reminder2_duedate'].'- 14 days'));}else{echo '00/00/0000';}?> </td>
<td class="bottomcolor"><?php if ($det[$i]['reminder2_duedate'] != '0000-00-00'){ echo date('d/m/Y',strtotime($det[$i]['reminder2_duedate'].'- 2 days'));}else{echo '00/00/0000';}?> </td>
<td class="bottomcolor"><?php echo isset($det[$i]['reminder2_status'])?($det[$i]['service_status']=='c')?'Completed':'Pending':'';?> </td>
</tr>
<?php }
}
else{ echo '<div class="row"><p style="text-align:center;"><strong>No records found</strong></p></div>';
} ?>
</table>
提醒者1
提醒2
问题出在这一行代码上
<td class="bottomcolor"><?php echo isset($det[$i]['reminder2_status'])?($det[$i]['service_status']=='c')?'Completed':'Pending':'';?> </td>
这将返回空值或空值您的问题是嵌套的三值运算符。如果您打算嵌套它们,至少使用括号来组织它们
<?php echo
(isset($det[$i]['reminder2_status'])?
($det[$i]['service_status']=='c' ? 'Completed' : 'Pending' )
: '' );?>
如果它返回一个空字符串,则表示未设置
$det[$i]['member2_status']]
。但是,它无法返回一个null
。这可能是因为$det[$i]['rements\u status']变量未定义。
检查调用mysql查询的$det变量。
确保通过mysql返回提醒_状态列