php - mysql通过php返回空值

标签 php mysql codeigniter

我正在开发一个项目,其中我需要通过电子邮件发送两个警报。我已经实现了一封电子邮件警报,其工作正常,在成功发送电子邮件后,我收到了已完成的状态消息,但对于第二封电子邮件,我又添加了一列作为 service_status。虽然电子邮件功能工作正常,但它没有显示已完成,而是显示 null 或空值,但数据库中的值是“已完成”...这是我的代码,我需要在其中显示已完成的结果

  <?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>      

问题出在这行代码

        <td class="bottomcolor"><?php echo isset($det[$i]['reminder2_status'])?($det[$i]['service_status']=='c')?'Completed':'Pending':'';?>          </td>

这将返回空值或 null 值

最佳答案

这可能是因为 $det[$i]['reminder_status'] 变量未定义。 检查调用 mysql 查询的 $det 变量。 确保通过mysql返回reminder_status列。

关于php - mysql通过php返回空值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16676336/

相关文章:

php - 如何正确管理 PHP 的用户权限?

codeigniter - 如何使我的 codeigniter url seo 友好

php - CodeIgniter:在一个循环中显示两个表中的数据

php - 如何在 codeigniter 中显示带有数据库中选定值的复选框列表

php - 通过ajax加载内容后Jquery不起作用

用于创建根符号链接(symbolic link)的 PHP exec 权限

php - 提交 php 表单时出现 "You have an error in your SQL syntax"错误

mysql管理产品尺寸的最佳方式

mysql - 获取表A中不存在的行

mysql - 选择将从表 1 中得出一个值并从表 2 中得出一个值的查询