1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
|
function diff_date($day , $month , $year , $day2 , $month2 , $year2){
/* fonction de calcul de différence de date */
$timestamp = mktime(0, 0, 0, $month, $day, $year);
$timestamp2 = mktime(0, 0, 0, $month2, $day2, $year2);
$diff_date = floor(($timestamp - $timestamp2) / (3600 * 24)); // Différence en jour entre le 2 dates
return $diff_date;
}
$queryStatus = "SELECT DateUp, field_6 FROM ibf_pfields_content";
$resultStatus = mysql_query($queryStatus, $db) or die($queryStatus . " - " . mysql_error());
while ($status = mysql_fetch_array($resultStatus))
{
list ($dateUpdate, $heure) = split(' +', $status['DateUp']);
list ($anneeUp, $moisUp, $jourUp) = split('-', $dateUpdate);
$le_jour = date("d");
$le_mois = date("m");
$l_annee = date("Y");
$difference = diff_date ($le_jour , $le_mois , $l_annee , $jourUp , $moisUp , $anneeUp);
switch (TRUE) {
case ($difference >=60 AND $difference < 120) :
$status["field_6"] = 'Abonné';
break;
case ($difference >= 120) :
$status["field_6"] = 'Inactif';
break;
default:
$status["field_6"] = 'Actif';
}
$upField6 = "UPDATE ibf_pfields_content SET field_6 ='".$status['field_6']."'";
$resField6 = mysql_query($upField6) or die(mysql_error());
} |
Partager