donc je reprend mon code (enfin celui que ma re écrit rawsrc que je remercie)...
grrr je lâcherais pas l’affaire il faut que je trouve.
donc pour verifier que ce n'etais pas mes champs date en vachar j'ai recrée une ligne date_end de type date.
alors si j'utilise date_fin (qui est en vachar tout passe en actif)
et si j'utilise date_end (qui est en date je passe en fin de durée)
je n'arrive pas a utiliser new datetime('now') car ma page bug ()
donc le code est comme ceci :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59 <?php $client = mysql_real_escape_string($client); $nom = mysql_real_escape_string($nom); $sql = "SELECT * FROM factures WHERE client='$client' AND nom='$nom' ORDER BY ordre DESC LIMIT 5"; $res = mysql_query($sql) or die ('Erreur : '.mysql_error()); $today = date("d/m/Y"); $etat5 = 'fin de durée'; $etat6 = 'actif'; $data = array(); $i = -1; while($row = mysql_fetch_assoc($res)) { $end = DateTime::createFromFormat("d/m/Y", $row['date_end']); $etat = ($today > $end) ? $etat5 : $etat6; $sql = "UPDATE factures SET etat='$etat' WHERE ordre={$row['ordre']}"; $exec = mysql_query($sql) or die ('Erreur : '.mysql_error()); $row['etat'] = $etat; // on conserve le dernier état connu if ($row['produit'] === 'points recharge') { $row['renouveler'] = '<font size="1" color="green"><b>Achat points</b></font>'; } else if ($row['etat'] === $etat5) { $row['renouveler'] = '<font size="1" color="red"><b><blink>Renouveler</blink></b></font>'; } else { $row['renouveler'] = '<font size="1" color="green"><b>Renouveler</b></font>'; } $row['tr_class'] = (++$i % 2) ? 'classe2' : 'classe1'; $data[] = $row; } ?> <table width="560" border="0"> <thead> <tr> <th class="td1" width="155">Produits</th> <th class="td1" width="157">Date achat</th> <th class="td1" width="137">Date de fin</th> <th class="td1" width="100">Etat</th> <th class="td1" width="137">Durée</th> <th class="td1" width="137">Renouveler</th> </tr> </thead> <tbody> <?php foreach($data as $row): ?> <tr class="prem <?php echo $row['tr_class']; ?>"> <td width="130"><font size="1"><?php echo $row['produit']; ?></font></td> <td width="130"><font size="1"><?php echo $row['date']; ?></font></td> <td width="137"><font size="1"><?php echo $row['date_fin']; ?></font></td> <td width="100"><font size="1"><?php echo $row['etat']; ?></font></td> <td width="137"><font size="1"><?php echo $row['duree']; ?></font></td> <td width="137"><?php echo $row['renouveler']; ?></td> </tr> <?php endforeach; ?> </tbody> </table>
en image :
resultat avec date_end (format DATE en sql)
et resultat avec date_fin (en type vachar sql)
donc la je ne comprend plus trop ...
merci de votre aide
Partager