我正在使用php java-script和html创建一个跟踪器。我需要检查所有记录的日期,并高亮显示所有距当前日期少于30天的单元格。
现在,我正在通过以下代码
<?php
$sql = "select * from vendor";
$conn = Database::connect ();
$stmt = $conn->prepare ( $sql );
$result = $stmt->execute ();
if ($result) {
foreach ( $stmt->fetchAll ( PDO::FETCH_FUNC, 'feat_product' ) as $row ) {
}
}
?>
function feat_product($bgserial, $claimexpiry, $expirydate, $projectcode,
$vendorname, $ponumber, $currency, $inhouse, $guarantee, $division,
$issuedate, $bgtype) {
echo '<tr>';
echo '<td>' . $bgserial . '</td>';
echo '<td>' . $claimexpiry . '</td>';
echo '<td>' . $expirydate . '</td>';
echo '<td>' . $vendorname . '</td>';
echo '<td>' . $projectcode . '</td>';
echo '<td>' . $ponumber . '</td>';
echo '<td>' . $currency . '</td>';
echo '<td>' . $inhouse . '</td>';
echo '<td>' . $guarantee . '</td>';
echo '<td>' . $division . '</td>';
echo '<td>' . $issuedate . '</td>';
echo '<td>' . $bgtype . '</td>';
echo '</tr>';
}
答案 0 :(得分:0)
我正在提交代码,只需根据您的变量输入变量名称即可:-
$today = date("d-m-Y") ;
$exp = date('d-m-Y',strtotime($exp_date));
$expDate = date_create($exp);
$todayDate = date_create($today);
$diff = date_diff($todayDate, $expDate);
if ($diff->format("%R%a") < 30){
//Your code here
}