php mysql更新第三列值,如果第一列值大于;第二列值

php mysql更新第三列值,如果第一列值大于;第二列值,php,mysql,mysqli,Php,Mysql,Mysqli,我正在比较1st[Sent]和2nd列[Last Update Date]的值。如果第1列的值大于第2列的值,则我希望在第3列[已尝试]中保存值“已尝试” 下面是完整的代码:试试这个(我使用了与您所需的相同的代码结构): 发送 最后更新日期 企图 <table> <tr> <th class="table-header">Sent</th> <th class="table-header">Last

我正在比较1st[Sent]和2nd列[Last Update Date]的值。如果第1列的值大于第2列的值,则我希望在第3列[已尝试]中保存值“已尝试”

下面是完整的代码:

试试这个(我使用了与您所需的相同的代码结构):


发送
最后更新日期
企图
    <table> 
<tr>           
<th class="table-header">Sent</th>
<th class="table-header">Last Update Date</th> 

<th class="table-header">Attempted</th> 
</tr>

<?php
if(!empty($orderrecords))
    {
      foreach($orderrecords as $k=>$v)
      {  
?>

<tr>
<td><?php echo $orderrecords[$k]["sent_date"]; ?></td>         
<td><?php echo $orderrecords[$k]["lud"]; ?></td> 

<td>
<?php 
$orderrecords[$k]["sent_date"]= strtotime($orderrecords[$k]["sent_date"]);
$orderrecords[$k]["lud"]=  strtotime($orderrecords[$k]["lud"]);

$sqlecom = 'UPDATE table SET attempted = "attempted" WHERE $orderrecords[$k]["lud"] < $orderrecords[$k]["sent_date"]';
$db_handleecom = new DBController(); 
$resultecom = $db_handleecom->executeUpdate($sqlecom); 


echo $orderrecords[$k]["attempted"];
?>

</td> 
</tr>

<?php
 }
 }
?>  

</table>      
<?php 

$orderrecords[$k]["sent_date"]= strtotime($orderrecords[$k]["sent_date"]);
$orderrecords[$k]["lud"]=  strtotime($orderrecords[$k]["lud"]);

if ($orderrecords[$k]["lud"] < $orderrecords[$k]["sent_date"])
    {
    $sqlecom = 'UPDATE table SET attempted = "attempted"
               WHERE id = ' . $orderrecords[$k]['id'];

    $db_handleecom = new DBController(); 
    $resultecom = $db_handleecom->executeUpdate($sqlecom);
    //echo "attempted";
} 

echo $orderrecords[$k]["attempted"];

?>
mysqli_report(MYSQLI_REPORT_ALL & ~MYSQLI_REPORT_INDEX);
<table> 
  <tr>           
    <th class="table-header">Sent</th>
    <th class="table-header">Last Update Date</th> 
    <th class="table-header">Attempted</th> 
  </tr>
<?php
  if(!empty($orderrecords)){
    foreach($orderrecords as $k=>$v){  
?>
<tr>
<td><?php echo $v["sent_date"]; ?></td>         
<td><?php echo $v["lud"]; ?></td> 
<?php 
  if ($v["lud"] < $v["sent_date"])  {
    $attempted= "attempted";
    $sqlecom = 'UPDATE table SET attempted = "attempted" WHERE ORDERID = '.$v["order_id"];
    $db_handleecom = new DBController(); 
    $resultecom = $db_handleecom->executeUpdate($sqlecom);
  }  
  else {
    $attempted = "";
  }

?>
<td><?php echo $attempted; ?></td> 
</tr>

<?php
    }
  }
?>  
</table>