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
|
$phrase_0 ="FROM `".$sufftable."table_1` D, `".$sufftable."table_2` G, `".$sufftable."table_3` U where ;
$phrase_1 = "SELECT D.champA , D.champB , G.champD, U.champE $phrase_0"; // en réalité il y a 30 champs sur 600 qui sont indiqués car je n'ai besoin que de ces 30 la.
$phrase_2 = "SELECT SUM(D.champA ) as com $phrase_0";
$phrase_3 = "SELECT SUM(D.champB ) as com $phrase_0";
$phrase_1_1='';
$phrase_2_2='';
$phrase_3_3='';
if ($searchstatut=="nouveau")
{
if ($c_annee<>""){$date_liste =" and (D.etude_A='$c_annee' or D.suivi_A='$c_annee')";} else {$date_liste =" and (D.date>'$time_c_jour' or D.datemodif>'$time_c_jour')";}
$phrase_1_1 .= " and D.suivi='' and D.etude=''";
$phrase_2_2 .= $phrase_1_1;
$phrase_3_3 .= $phrase_1_1;
}
$phrase0 = " D.idCT=G.idCT and G.idGEST=U.idUT";
$toto = $phrase_1.$phrase0.$date_liste.$secureclient;
$phrase_1 = $phrase_1.$phrase0.$phrase_1_1.$date_liste;
$resultat = mysql_query("$phrase_1 group by D.idCLIENT order by D.idCLIENT desc");
$nbresultat =mysql_num_rows($resultat);
$phrase_2 = $phrase_2.$phrase0.$phrase_2_2.$date_liste.$secureclient;
$phrase_3 = $phrase_3.$phrase0.$phrase_3_3.$date_liste.$secureclient;
$res = mysql_query("$phrase_1 group by D.idCLIENT order by D.idCLIENT desc");
$res_2 = mysql_query("$phrase_2 order by D.idCLIENT desc");
$res_3 = mysql_query("$phrase_3 order by D.idCLIENT desc");
$totchampA = mysql_result($res_2, 0, 'com'); $totchampA = number_format($totchampA , 2, ',', ' ');
$totchampB = mysql_result($res_3, 0, 'com'); $totchampB = number_format($totchampB , 2, ',', ' ');
$nbmaxres =mysql_num_rows($res);
/// le header de mon tableau
while($cl = mysql_fetch_array($res, MYSQL_ASSOC))
{
$idCT =$cl['idCT'];
$idGEST=$cl['idGEST']; /// .....
/// echo 'mes resultats';
$res_journal = mysql_query("SELECT * FROM `".$sufftable."journal` where idCT='$idCT ' and ip='$ip'");
$nb_journal =mysql_num_rows($res_journal );
if ($nb_journal =="0"){$modif=mysql_query("INSERT INTO `".$sufftable."journal` (`idCT`,`idGEST`,`date`,`ip`) VALUES ('$idcl','$idGEST','$auj','$ip')");}
else {$modif = mysql_query("UPDATE `".$sufftable."journal` SET `date` = '$auj' WHERE `idCT` = '$idCT' and `ip`='$ip' ");
} |
Partager