php - Separating Results Within a Number of Different Date Ranges -
i need have table splits dates into:
1. if date within next 30 days - reddish 2. if date on 30 days under 60 - orange 3. if date on 60 days - greenish
i cannot seem right. here select statement returns results:
$result = mysqli_query($con,"select a.id, a.title, b.value_id, b.uf_crm_1410772281, b.uf_crm_1410772330 b_crm_company inner bring together b_uts_crm_company b on a.id = b.value_id uf_crm_1410772281 = 1 grouping a.title order uf_crm_1410772330 asc");
here while loop displays results in table. see have tried seperate dates between results specified above (please note table begins before select statement):
<table width="475"> <tr><th width="275"><b>company</b></th><th width="200"><b>renewal date</b></th></tr> while($row = mysqli_fetch_array($result)) { $companyname = $row['title']; $supportrenewal = date('d/m/y',strtotime($row['uf_crm_1410772330'])); $id = $row['id']; if(strtotime($row['uf_crm_1410772330']) < strtotime('+30 day')) { print "<tr><td><strong style='color:#ff0000;'>$companyname</strong></td><td> <strong style='color:#ff0000;'>$supportrenewal</span></td></tr>"; } if ((strtotime($rows['uf_crm_1410772330']) > strtotime('+30 day')) , (strtotime($rows['uf_crm_1410772330']) < strtotime('+60 day'))) { print "<tr><td><strong style='color:#ff8400;'>$companyname</strong></td> <td><strong style='color:#ff8400;'>$supportrenewal</span></td></tr>"; } if(strtotime($row['uf_crm_1410772330']) > strtotime('+90 day')) { print "<tr><td><strong style='color:#ff0000;'>$companyname</strong></td><td> <strong style='color:#ff0000;'>$supportrenewal</span></td></tr>"; } } ?> </table>
this doesn't seem work when thought would, point out going wrong
you should this
<?php $array = array('2014-11-15','2014-12-08','2015-01-10','2015-7-05'); foreach($array $date) { $now = strtotime(date('y-m-d')); $newdate = strtotime($date); if($newdate > $now) { $datediff = ($newdate - $now)/(24*60*60); echo $datediff; if($datediff > 1 && $datediff <= 30) { echo "red =======<br>"; } else if($datediff > 30 && $datediff < 60) { echo "orange =======<br>"; } else { echo "green =======<br>"; } } } ?>
implement in code.
<table width="475"> <tr><th width="275"><b>company</b></th><th width="200"><b>renewal date</b></th></tr> while($row = mysqli_fetch_array($result)) { $companyname = $row['title']; $id = $row['id']; $now = strtotime(date('y-m-d')); $supportrenewal = strtotime($row['uf_crm_1410772330']); $datediff = ($supportrenewal - $now)/(24*60*60); if($datediff <= 30) { print "<tr><td><strong style='color:#ff0000;'>$companyname</strong></td><td> <strong style='color:#ff0000;'>date('y-m-d',$supportrenewal)</span></td></tr>"; } if($datediff > 30 && $datediff < 60) { print "<tr><td><strong style='color:#ff8400;'>$companyname</strong></td> <td><strong style='color:#ff8400;'>date('y-m-d',$supportrenewal)</span></td></tr>"; } if($datediff > 60) { print "<tr><td><strong style='color:#ff0000;'>$companyname</strong></td><td> <strong style='color:#ff0000;'>date('y-m-d',$supportrenewal)</span></td></tr>"; } } ?> </table>
php mysql
No comments:
Post a Comment