j'ai une requête PHP qui me donne un nombre de résultats attendus:
2 lignes exactements
j'aimerai implémenter une boucle qui me permettrait de faire apparaître un message du style "le résultat 1 est manquant" ou "le résultat 2 est manquant" ou "les 2 résultats sont manquants"
j'ai tenté une boucle foreach mais ça me donne un résultat erroné:
mes 2 lignes sont présentes mais il renvoie aussi par 2 fois "le résultats 1 est manquant"
voici mon code
d'avance merci
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 <?php include ("titre.php"); $paire = 0; reset ($rows17); foreach ($rows17 as $row17) { if ($row17['dbtimestamp_log']!="") { list($chaine,$script) = explode(";",preg_replace("#(.*?)([^/]+)/(?:bin/)?([^/]*?)$#i","\\2;\\3",$row17["script_log"])); ?> <tr class="<?php echo ($paire==1?"paire":"impaire"); ?>" style="color:<?php echo ($row17["Duree"]!=''?($row17["returncode_log"]==0?"green":($row17["returncode_log"]<16?"orange":"red")):"black"); ?>"> <td> <?php if ($row17["jobname_log"] =="") { echo 'Job UNIX'; } else { echo $row17["jobname_log"];} ?></td> <td><?php echo ($row17["dbendstamp_log"]!='0000-00-00 00:00:00'?$row17["dbendstamp_log"]:"En cours"); ?></td> <td><?php echo ($script!=""?$chaine:"PATH"); ?></td> <td><?php echo ($script!=""?$script:$chaine); ?></td> <td title="<?php echo $row17['args_log']?>"><?php echo substr($row17['args_log'],0,20).(strlen($row17['args_log'])>20?'...':''); ?></td> </tr> <?php $array =array('premier'=>'pubMCourante.pl', 'deuxieme'=>'pubMCOpsim.pl') ?> <?php } else { foreach ($array as $value){ if ($script !=$value[1]){ echo "<tr><td colspan='5' valign='top'><b>pubMCourante n'a pas tourné</b></td></tr>";} elseif ($script !=$value[2]){ echo "<tr><td colspan='5' valign='top'><b>pubMCOpSim n'a pas tourné</b></td></tr>";} elseif ($script !=$value[1] && $script !=$value[2]){ echo "<tr><td colspan='5' valign='top'><b>pubMCourante et pubMCopSim n'ont pas tourné</b></td></tr>";} else{} } } $paire = (abs($paire-1)); };
Partager