2013-05-21 74 views
0

我正在一個項目,我需要通過電子郵件發送兩個警報。我已經實施了一個電子郵件提醒,它的工作正常,我收到狀態消息後成功完成電子郵件交付完成,但對於第二個我已經添加了一列作爲service_status。雖然電子郵件功能工作正常,但它沒有顯示完成,而是顯示空值或空值,但數據庫中的值是「已完成」...這裏是我的代碼片段,我需要顯示已完成的結果空值是從MySQL返回通過PHP

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

這是返回空或空值

回答

1

它可能是因爲$ det [$ i] ['reminder_status']變量未定義。 檢查您在其中調用mysql查詢的$ det變量。 確保reminder_status列是通過mysql返回的。

1

您的問題是你的嵌套三元運營商。如果您打算嵌套它們,至少使用括號來組織它們。

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

如果它返回一個空字符串,則表示沒有設置$det[$i]['reminder2_status']。但是它沒有辦法返回null