affichage d'un ensemble de mes tables
bonjour ,j'ai un code qui ne contient plus de message d'erreur , dans ma requête il m'a permi de faire une jointure, c'est à dire d'accéder à l'information 'libelle' dans la table 'mo'. Mais la valeur de 'code-mo' reste la même. Donc si je veux afficher le libelle, c'est mo.libelle qu'il me faudra utiliser.Et pour cela j'ai besoin de vos aides pour afficher "localisation.libelle","nature.libelle","code.libelle","etat.libelle","date.debut" ,je vous envoie le code entier:
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 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76
| <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" >
<head>
<title> gestion de projet </title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
</head>
<body>
<?php
$conn =("host=localhost port=5432 dbname=gdt user=postgres password=gabero");
$dbconn = pg_connect("$conn");
// connexion à une base de données nommée "gdt" sur l'hôte "localhost" avec un
// nom d'utilisateur"postgres" et un mot de passe"gabero"
// éxecution de la requète SQL
$sql = pg_query('SELECT projet."id-projet",projet."nom-projet",projet."id-date",projet."id-nature",projet."code-localisation",projet."code-etat",projet."code-mo",projet."resultat-projet",projet."montant-projet",
localisation."libelle",mo."libelle",nature."libelle",date."date-debut",etat."libelle"
FROM projet
INNER JOIN date
ON projet."id-date"= date."id-date"
INNER JOIN etat
ON projet."code-etat" = etat."code-etat"
INNER JOIN nature
ON projet."id-nature" = nature."id-nature"
INNER JOIN mo
ON projet."code-mo" = mo."code-mo"
INNER JOIN localisation
ON projet."code-localisation" = localisation."code-localisation"
WHERE projet."id-nature" = 1
AND projet."id-date" = 1
AND projet."code-etat"= 1
AND projet."code-localisation" = 1
AND projet."code-mo" = 1');
;
//En-tete du tableau
echo "<table border='1' >
<caption><strong> PROJET</strong></caption>
<tr>
<td>id-projet</td>
<td>nom-projet</td>
<td>code-mo</td>
<td>resultat-projet</td>
<td>montant-projet</td>
<td>code-localisation</td>
<td>id-nature</td>
<td>id-date</td>
<td>code-etat</td>
</tr>";
// utilisation de la boucle tant que
while($infos = pg_fetch_array($sql)) {
// affichage des resultats
echo"<tr>";//ligne du tableau
echo "<td>";echo $infos['id-projet'];echo "</td>";
echo "<td>";echo $infos['nom-projet'];echo "</td>";
echo "<td>";echo $infos['code-mo'];echo "</td>";
echo "<td>";echo $infos['resultat-projet'] ;echo "</td>";
echo "<td>";echo $infos['montant-projet'] ;echo "</td>";
echo "<td>";echo $infos['code-localisation'] ;echo "</td>";
echo "<td>";echo $infos['id-nature'] ;echo "</td>";
echo "<td>";echo $infos['id-date'] ;echo "</td>";
echo "<td>";echo $infos['code-etat'];echo "</td>";
echo"</tr>"; //fermeture de la ligne
} //fermeture du tant que
echo "</table>";//fermeture du tableau
pg_close($dbconn);
?>
</body>
</html> |
affichage d un sous ensemble de mes tables
bonjour,merci pour vos contributions mais je continu toujours à avoir des messages d erreur qui sont les suivants:
Warning: pg_query() [function.pg-query]: Query failed: ERROR: syntax error at or near "-" LINE 2: localisation."libelle" as lo-libelle,mo."libelle" as mo-lib... ^ in C:\wamp\www\gdt\projets[1].php on line 38
je vous envoie le code entier avec les nouvelles modifications .
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 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
| <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" >
<head>
<title> gestion de projet </title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
</head>
<body>
<?php
$conn =("host=localhost port=5432 dbname=gdt user=postgres password=gabero");
$dbconn = pg_connect("$conn");
// connexion à une base de données nommée "gdt" sur l'hôte "localhost" avec un
// nom d'utilisateur"postgres" et un mot de passe"gabero"
// éxecution de la requète SQL
$sql = pg_query('SELECT projet."id-projet",projet."nom-projet",projet."id-date",projet."id-nature",projet."code-localisation",projet."code-etat",projet."code-mo",projet."resultat-projet",projet."montant-projet",
localisation."libelle" as lo-libelle,mo."libelle" as mo-libelle,nature."libelle" as na-libelle ,date."date-debut",etat."libelle" as eta-libelle
FROM projet
INNER JOIN date
ON projet."id-date"= date."id-date"
INNER JOIN etat
ON projet."code-etat" = etat."code-etat"
INNER JOIN nature
ON projet."id-nature" = nature."id-nature"
INNER JOIN mo
ON projet."code-mo" = mo."code-mo"
INNER JOIN localisation
ON projet."code-localisation" = localisation."code-localisation"
WHERE projet."id-nature" = 1
AND projet."id-date" = 1
AND projet."code-etat"= 1
AND projet."code-localisation" = 1
AND projet."code-mo" = 1');
//En-tete du tableau
echo "<table border='1' >
<caption><strong> PROJET</strong></caption>
<tr>
<td>id-projet</td>
<td>nom-projet</td>
<td>code-mo</td>
<td>resultat-projet</td>
<td>montant-projet</td>
<td>code-localisation</td>
<td>id-nature</td>
<td>id-date</td>
<td>code-etat</td>
<td>lo-libelle</td>
<td>mo-libelle</td>
<td>na-libelle</td>
<td>eta-libelle</td>
<td>date-debut</td>
</tr>";
// utilisation de la boucle tant que
while($infos = pg_fetch_array($sql)) {
// affichage des resultats
echo"<tr>";//ligne du tableau
echo "<td>";echo $infos['id-projet'];echo "</td>";
echo "<td>";echo $infos['nom-projet'];echo "</td>";
echo "<td>";echo $infos['code-mo'];echo "</td>";
echo "<td>";echo $infos['resultat-projet'] ;echo "</td>";
echo "<td>";echo $infos['montant-projet'] ;echo "</td>";
echo "<td>";echo $infos['code-localisation'] ;echo "</td>";
echo "<td>";echo $infos['id-nature'] ;echo "</td>";
echo "<td>";echo $infos['id-date'] ;echo "</td>";
echo "<td>";echo $infos['code-etat'];echo "</td>";
echo "<td>";echo $infos['lo-libelle'];echo "</td>";
echo "<td>";echo $infos['mo-libelle'];echo "</td>";
echo "<td>";echo $infos['na-libelle'];echo "</td>";
echo "<td>";echo $infos['eta-libelle'];echo "</td>";
echo "<td>";echo $infos['date-debut'];echo "</td>";
echo"</tr>"; //fermeture de la ligne
} //fermeture du tant que
echo "</table>";//fermeture du tableau
pg_close($dbconn);
?>
</body>
</html>
merci de m avoir aider |
affichage d un sous ensemble de mes tables
bonjour ,merci à vous tous j'ai resolu le problème il fallait ajouter des quotes a partie select
exemple:localisation."libelle" as "lo-libelle"
au lieu de localisation."libelle" as lo-libelle.
Ce que je veux maintenant c'est inserer un compteur dans la partie WHERE de mon code:
Code:
1 2 3 4 5
| WHERE projet."id-nature" = 1
AND projet."id-date" = 1
AND projet."code-etat"= 1
AND projet."code-localisation" = 1
AND projet."code-mo" = 1' |
pour qu'elle puisse incrementer automatiquement les diffrents identifiants(id-date,code-etat,code-localisation,code-mo,id-nature)
pour cela voici le code entier
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 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83
| <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" >
<head>
<title> gestion de projet </title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
</head>
<body>
<?php
$conn =("host=localhost port=5432 dbname=gdt user=postgres password=gabero");
$dbconn = pg_connect("$conn");
// connexion à une base de données nommée "gdt" sur l'hôte "localhost" avec un
// nom d'utilisateur"postgres" et un mot de passe"gabero"
// éxecution de la requète SQL
$sql = pg_query('SELECT projet."id-projet",projet."nom-projet",projet."id-date",projet."id-nature",projet."code-localisation",projet."code-etat",projet."code-mo",projet."resultat-projet",projet."montant-projet",
localisation."libelle" as "lo-libelle",mo."libelle" as "mo-libelle",nature."libelle" as "na-libelle" ,date."date-debut",etat."libelle" as "eta-libelle"
FROM projet
INNER JOIN date
ON projet."id-date"= date."id-date"
INNER JOIN etat
ON projet."code-etat" = etat."code-etat"
INNER JOIN nature
ON projet."id-nature" = nature."id-nature"
INNER JOIN mo
ON projet."code-mo" = mo."code-mo"
INNER JOIN localisation
ON projet."code-localisation" = localisation."code-localisation"
WHERE projet."id-nature" = 1
AND projet."id-date" = 1
AND projet."code-etat"= 1
AND projet."code-localisation" = 1
AND projet."code-mo" = 1');
//En-tete du tableau
echo "<table border='1' >
<caption><strong> PROJET</strong></caption>
<tr>
<td>id-projet</td>
<td>nom-projet</td>
<td>code-mo</td>
<td>resultat-projet</td>
<td>montant-projet</td>
<td>code-localisation</td>
<td>id-nature</td>
<td>id-date</td>
<td>code-etat</td>
<td>lo-libelle</td>
<td>mo-libelle</td>
<td>na-libelle</td>
<td>eta-libelle</td>
<td>date-debut</td>
</tr>";
// utilisation de la boucle tant que
while($infos = pg_fetch_array($sql)) {
// affichage des resultats
echo"<tr>";//ligne du tableau
echo "<td>";echo $infos['id-projet'];echo "</td>";
echo "<td>";echo $infos['nom-projet'];echo "</td>";
echo "<td>";echo $infos['code-mo'];echo "</td>";
echo "<td>";echo $infos['resultat-projet'] ;echo "</td>";
echo "<td>";echo $infos['montant-projet'] ;echo "</td>";
echo "<td>";echo $infos['code-localisation'] ;echo "</td>";
echo "<td>";echo $infos['id-nature'] ;echo "</td>";
echo "<td>";echo $infos['id-date'] ;echo "</td>";
echo "<td>";echo $infos['code-etat'];echo "</td>";
echo "<td>";echo $infos['lo-libelle'];echo "</td>";
echo "<td>";echo $infos['mo-libelle'];echo "</td>";
echo "<td>";echo $infos['na-libelle'];echo "</td>";
echo "<td>";echo $infos['eta-libelle'];echo "</td>";
echo "<td>";echo $infos['date-debut'];echo "</td>";
echo"</tr>"; //fermeture de la ligne
} //fermeture du tant que
echo "</table>";//fermeture du tableau
pg_close($dbconn);
?>
</body>
</html> |