Précédent   Forum des professionnels en informatique > PHP > PHP & SGBD > PHP & MySQL
PHP & MySQL Forum d'entraide sur les fonctions MySQL avec PHP. Avant de poster -> FAQ MySQL, Cours MySQL et Sources MySQL. Pour les questions concernant le moteur MySQL plutôt que les fonctions PHP, merci d'utiliser le forum MySQL.
Partagez cette discussion sur d'autres réseaux sociaux : Viadeo Twitter Google Facebook Digg Delicious MySpace Yahoo
Réponse Proposer ce sujet en actualité
 
Outils de la discussion
Publicité
'
Vieux 12/12/2011, 01h36   #1
Invité de passage
 
Femme
Inscription : novembre 2011
Messages : 26
Détails du profil
Informations personnelles :
Sexe : Femme

Informations forums :
Inscription : novembre 2011
Messages : 26
Points : 0
Points : 0
Par défaut exploitation des données de la base de données

Salut,
Je veux savoir si ce code est juste :
Code :
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
 
 <?php
 
mysql_connect("localhost", "root", ""); // Connexion à MySQL
mysql_select_db("alu"); // Sélection de la base 
 
$reponse = mysql_query("SELECT p.nom_projet as nom_projet,d.id_demande as num_demande ,d.borderaux_client as borderaux, COUNT(dp2.num_serie) as nb_cinqjour ,COUNT(dp3.num_serie) as nb_quinzejour,COUNT(dp4.num_serie) as nb_trentejour FROM demande d
LEFT JOIN demande_projet dpp on d.id_demande=dpp.id_demande
LEFT JOIN projet p on d.id_demande=dpp.id_demande AND dpp.id_projet=p.id_projet
LEFT JOIN demande_produit dp2 on d.id_demande=dp2.id_demande AND DATEDIFF(CURDATE(),ADDDATE(dp2.date_entree, INTERVAL '70' DAY))>0 
LEFT JOIN demande_produit dp3 on d.id_demande=dp3.id_demande AND DATEDIFF(CURDATE(),ADDDATE(dp3.date_entree, INTERVAL '60' DAY))>0
LEFT JOIN demande_produit dp4 on d.id_demande=dp4.id_demande AND DATEDIFF(CURDATE(),ADDDATE(dp4.date_entree, INTERVAL '45' DAY))>0
GROUP BY d.id_demande")or die( mysql_error() );
 
 
 
echo "<table width=\"435\" align=\"center\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">
 
    echo "<tr>
    <td height=\"22\">&nbsp;</td>
	<td valign=\"top\" bgcolor=\"#6699FF\"><b>Nom projet</b>&nbsp;</td>
    <td>&nbsp;</td>
	<td valign=\"top\" bgcolor=\"#6699FF\"><b>Num&eacute;ro demande</b>&nbsp;</td>
    <td>&nbsp;</td>
	<td valign=\"top\" bgcolor=\"#6699FF\"><b>Borderaux client</b>&nbsp;</td>
    <td>&nbsp;</td>
    <td valign=\"top\" bgcolor=\"#6699FF\"><b>Produits avec &eacute;ch&eacute;ance 5j</b>&nbsp;</td>
    <td>&nbsp;</td>
	<td valign=\"top\" bgcolor=\"#6699FF\"><b>Produits avec &eacute;ch&eacute;ance 15j</b>&nbsp;</td>
    <td>&nbsp;</td>
	<td valign=\"top\" bgcolor=\"#6699FF\"><b>Produits avec &eacute;ch&eacute;ance 30j</b>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>";
 
while ($donnees = mysql_fetch_array($reponse) )
{
 
 
 
echo '<td height="22">&nbsp;</td>
 <td valign="top">'.$donnees['nom_projet'].'&nbsp;</td>
    <td>&nbsp;</td>
    <td valign="top">'.$donnees['num_demande'].'&nbsp;</td>
    <td>&nbsp;</td>
    <td valign="top">'.$donnees['borderaux'].'&nbsp;</td>
    <td>&nbsp;</td>
    <td valign="top">'.$donnees['nb_cinqjour'].'&nbsp;</td>
    <td>&nbsp;</td>
	<td valign="top">'.$donnees['nb_quinzejour'].'&nbsp;</td>
    <td>&nbsp;</td>
    <td valign="top">'.$donnees['nb_trentejour'].'&nbsp;</td>
    <td>&nbsp;</td>
 
  </tr>';
 
 
}
 echo "</table>";
mysql_close(); // Déconnexion de MySQL
 ?>
Car les colonnes produits avec echeance 5j ,15j et 30j me retourne 0
angelina88 est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 12/12/2011, 10h29   #2
Rédacteur/Modérateur
 
Avatar de MaitrePylos
 
Homme Gérard Ernaelsten
DBA & Dev PHP
Inscription : juin 2005
Messages : 3 182
Détails du profil
Informations personnelles :
Nom : Homme Gérard Ernaelsten
Âge : 39
Localisation : Belgique

Informations professionnelles :
Activité : DBA & Dev PHP
Secteur : Service public

Informations forums :
Inscription : juin 2005
Messages : 3 182
Points : 6 470
Points : 6 470
Essayer votre requête dans WorkBench !

Il manque des éléments dans le GROUP BY
MaitrePylos est déconnecté   Envoyer un message privé Réponse avec citation 00
Réponse Proposer ce sujet en actualité
Outils de la discussion



Fuseau horaire GMT +2. Il est actuellement 01h26.


 
 
 
 
Partenaires

Hébergement Web