Bonjour,

J'essaye de mettre en place un récapitulatif des montants de ma base de donnée par année et par région, mais voila le code de mon script est mal interprété
Ci-joint la structure de mes deux table concerné

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
 
 
--
-- Structure de la table `facture`
--
 
CREATE TABLE IF NOT EXISTS `facture` (
  `fact_id` varchar(7) NOT NULL,
  `fact_facture` varchar(14) NOT NULL,
  `fact_intitule` varchar(60) NOT NULL,
  `fact_montant` double NOT NULL,
  `fact_session` tinytext NOT NULL,
  `fact_date` varchar(20) NOT NULL,
  `fact_echeance` varchar(20) NOT NULL,
  `fact_type` varchar(15) NOT NULL,
  `fact_annee` varchar(5) NOT NULL,
  PRIMARY KEY (`fact_facture`),
  UNIQUE KEY `facture` (`fact_facture`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
 
-- --------------------------------------------------------
 
--
-- Structure de la table `societe`
--
 
CREATE TABLE IF NOT EXISTS `societe` (
  `soc_id` varchar(7) NOT NULL,
  `soc_societe` tinytext NOT NULL,
  `soc_adherent` tinytext NOT NULL,
  `soc_adressea` tinytext NOT NULL,
  `soc_adresseb` tinytext NOT NULL,
  `soc_postal` varchar(30) NOT NULL,
  `soc_ville` tinytext NOT NULL,
  `soc_region` tinytext NOT NULL,
  `soc_enseigne` tinytext NOT NULL,
  `soc_telephone` tinytext NOT NULL,
  `soc_fax` tinytext NOT NULL,
  `soc_siret` tinytext NOT NULL,
  `soc_code` varchar(1) NOT NULL,
  PRIMARY KEY (`soc_id`),
  UNIQUE KEY `id_numero` (`soc_id`),
  UNIQUE KEY `id_numero_2` (`soc_id`),
  KEY `id_numero_3` (`soc_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
et le code de ma page

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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
 
<?php
session_start ();
echo "Utilisateur : ";
echo $_SESSION['pseudo'];
if (($_SESSION['level']==1) AND ($_SESSION['level']==2))
header('location:../index.php');
echo'<br>';
?>
 
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<link rel="stylesheet" media="screen" type="text/css" title="Design" href="#" />
</head>
 
<body font-size='xx-small'>
 
<h2><center><b><u> Récapitulatif </u></b></center></h2><br>
 
<?php
 
include('../inc/inc_connexion.php');
include('../inc/fonction.php');
 
$ligne = "<table BORDER=1 BORDERCOLOR=#CCCCCC BGCOLOR=#fffccc CELLSPACING=0 CELLPADDING=1 WIDTH=98% ALIGN=center font-family='Verdana' font-size='xx-small' >
			<td bgcolor='#669999'><b><u>region</u></b></td>
			<td bgcolor='#669999' WIDTH=15px><b><u>Montant</u></b></td>
			<td bgcolor='#669999' WIDTH=15px><b><u>Anterieur à 2008</u></b></td>
			<td bgcolor='#669999' WIDTH=15px><b><u>2008</u></b></td>
			<td bgcolor='#669999' WIDTH=15px><b><u>2009</u></b></td>
			<td bgcolor='#669999' WIDTH=15px><b><u>2010</u></b></td>
			<td bgcolor='#669999' WIDTH=15px><b><u>2011</u></b></td>
			<td bgcolor='#669999' WIDTH=15px><b><u>-1 mois</u></b></td>
			<td bgcolor='#669999' WIDTH=15px><b><u>Vérif</u></b></td>";
 
$total = 0;	
//ici initialisation des variables total pour chaque année//
		$Tant08 = 0;
		$Ta08 = 0;
		$Ta09 = 0;
		$Ta10 = 0;
		$Ta11 = 0;
		$Ta_1 = 0; //c'est pour les facture datant d'un - d'un mois ($Ta_1)//
		$Tmont_3 = 0; // sert à la totalisation de la colonne des totaux
 
$rqt = mysql_query("SELECT fact_id, soc_ville, soc_telephone, soc_fax, soc_siret, soc_enseigne,soc_code, soc_region, soc_societe, SUM(fact_montant) AS fact_montant, soc_adherent, fact_annee FROM societe, facture WHERE fact_id = soc_id GROUP BY soc_code") or die(mysql_error());
 
 
if(mysql_num_rows($rqt) > 0)
	{
	while($tableau = mysql_fetch_array($rqt))
		{
		$id = $tableau['fact_id'];
		$code = $tableau['soc_code'];
		$societe = $tableau['soc_societe'];
		$adherent = $tableau['soc_adherent'];
		$ville = $tableau['soc_ville'];
		$region = $tableau['soc_region'];
		$enseigne = $tableau['soc_enseigne'];
		$telephone = $tableau['soc_telephone'];
		$fax = $tableau['soc_fax'];
		$siret = $tableau['soc_siret'];
 
		$ant08 = 0; //ici l'initialisation des variables par année//
		$a08 = 0;
		$a09 = 0;
		$a10 = 0;
		$a11 = 0;
		$a_1 = 0;
		$Tmont_2 = 0; // sert a la totalisation des lignes
 
		$mont = 0;
 
//********************************************************************************//		
//                              calcul par année                                 //
//******************************************************************************//
 
			if($tableau['fact_annee'] == '20081')
				{
				$ant08 += $tableau['fact_montant']; //anterieur a 2008
				}
			if($tableau['fact_annee'] == '20080')
				{
				$a08 += $tableau['fact_montant']; // année 2008
				}
			if($tableau['fact_annee'] == '20090')
				{
				$a09 += $tableau['fact_montant']; // année a 2009
				}
			if($tableau['fact_annee'] == '20100')
				{
				$a10 += $tableau['fact_montant']; // année a 2010
								}
			if($tableau['fact_annee'] == '20110')
				{
				$a11 += $tableau['fact_montant'];  // année a 2011
				}
			if($tableau['fact_annee'] == '20101')
				{
				$a_1 += $tableau['fact_montant'];  // Mons d'un mois
				}
			//fin du calcul par année//
			$mont += $tableau['fact_montant'];
 
//***********************************************************************************************************************//		
//                                 Totalisation par colonne selon l'année                                                //
//***********************************************************************************************************************//
			if(($tableau['soc_code'] == $code) AND ($tableau['soc_region'] == $region))
				{
				$Tant08 += $ant08;
				}
			if(($tableau['soc_code'] == $code) AND ($tableau['soc_region'] == $region))
				{
				$Ta08 += $a08;
				}
			if(($tableau['soc_code'] == $code) AND ($tableau['soc_region'] == $region))
				{
				$Ta09 += $a09;
				}	
			if(($tableau['soc_code'] == $code) AND ($tableau['soc_region'] == $region))
				{
				$Ta10 += $a10;
				}	
			if(($tableau['soc_code'] == $code) AND ($tableau['soc_region'] == $region))
				{
				$Ta11 += $a11;
				}	
			if(($tableau['soc_code'] == $code) AND ($tableau['soc_region'] == $region))
				{
				$Ta_1 += $a_1;
				}
			// fin du calcul des totaux par colonne
 
 
//**************************************************************************************			
// création du total par ligne " vérification avec le fact_montant "
 
$Tmont_2 = ($ant08 + $a08 + $a09 + $a10 + $a11 + $a_1); 
 
//*************************************************************************************	
			$Tmont_3 += $Tmont_2;
 
 
//*****************************************************************************************
// Calcul du total final par région
 
		$total += $mont; 
 
//**********************************************************************************************************************
 
		if($mont > 0)
			{
			$ligne .= "<tr>
						<td><font size ='2.5'>".$region."<font></td>
						<td align='right' bgcolor='#669999'><font size ='2.5'>".$mont."<font></td>
						<td align='right'><font size ='2.5'>".$ant08."<font></td>
						<td align='right'><font size ='2.5'>".$a08."<font></td>
						<td align='right'><font size ='2.5'>".$a09."<font></td>
						<td align='right'><font size ='2.5'>".$a10."<font></td>
						<td align='right'><font size ='2.5'>".$a11."<font></td>
						<td align='right'><font size ='2.5'>".$a_1."<font></td>
						<td align='right' bgcolor='#669999'><font size ='2.5'>".$Tmont_2."<font></td></tr>"; // total de la ligne //
			}
		}	
 
$ligne .= "<tr><td colspan='1' bgcolor='#669999'><font size ='2.5'>Total Final<font></td><td align='right' bgcolor='#669999'><font size ='2.5'>".$total."<font></td>";
$ligne .= "<td colspan='1' align='right' bgcolor='#669999'><font size ='2.5'>".$Tant08."<font></td>";
$ligne .= "<td colspan='1' align='right' bgcolor='#669999'><font size ='2.5'>".$Ta08."<font></td>";
$ligne .= "<td colspan='1' align='right' bgcolor='#669999'><font size ='2.5'>".$Ta09."<font></td>";
$ligne .= "<td colspan='1' align='right' bgcolor='#669999'><font size ='2.5'>".$Ta10."<font></td>";
$ligne .= "<td colspan='1' align='right' bgcolor='#669999'><font size ='2.5'>".$Ta11."<font></td>";
$ligne .= "<td colspan='1' align='right' bgcolor='#669999'><font size ='2.5'>".$Ta_1."<font></td>"; // concerne les factures de moins d'un mois //
$ligne .= "<td colspan='1' align='right' bgcolor='#669999'><font size ='2.5'>".$Tmont_3."<font></td></tr>"; // total des differents totaux //
	}
 
$ligne .= "</table>";	
 
echo ("$ligne </br>");
 
?>

Je vous remerci de l'aide que vous pourriez m'apporter.

Ci-joint en pièce joint le résultat obtenu à ce jour

Runcafre91