affichage d'un sous-ensemble de mes tables
Bonjour,ce que je veux c'est exploiter ,ensemble les differentes tables de ma base pour afficher toutes les informations rélatives à chaque projet ou du moins un bon sous-ensemble,pour cela j'ai fais la jointures de ma table principale "projet" avec les autres tables(localisation,mo,nature,date,etat) qui sont liées à la table projet par des identifiants(clefs étrangères dans la table projet). je voudrais que vous m'aider à corriger ce que ne va pas dans mon code et j'obtiens le message d'erreur suivant : parse error in C:\wamp\www\gdt\php.php on line 33 ,ça concerne la ligne "where"et je pense qu'il ya d'autres incorrections dans la partie select,je me demande aussi si l'on doit pas changer quelque chose dans la partie "while" 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
| <!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.debut-date,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 localistion
ON projet.code-localisation = localisation.code-localisation ")
where id-nature = 1
AND id-date =1
AND code-etat =1
AND code-localisation =1
AND code-mo =1 ;
?>
<!-- En-tete du tableau -->
<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>
<?php
// utilisation de la boucle tant que
while($infos = pg_fetch_array($sql)) {
// affichage des resultats
echo"<tr>";//ligne du tableau
echo "<td>".$infos['id-projet']."</td>";
echo "<td>".$infos['nom-projet']."</td>";
echo "<td>".$infos['code-mo']."</td>";
echo "<td>".$infos['resultat-projet']."</td>";
echo "<td>".$infos['montant-projet']."</td>";
echo "<td>".$infos['code-localisation']."</td>";
echo "<td>".$infos['id-nature']."</td>";
echo "<td>".$infos['id-date']."</td>";
echo "<td>".$infos['code-etat']."</td>";
echo"</tr>"; //fermeture de la ligne
} //fermeture du tant que
?>
</table> <!--fermeture du tableau-->
<?php pg_close($dbconn);
?>
</body>
</html> |
merci d'avance.vos contributions seront les bienvenues
affichage d'un sous-ensemble de mes tables
merci pour la remarque,mais je continue à avoir des messages:
Citation:
Warning: pg_query() [function.pg-query]: Query failed: ERROR: syntax error at end of input LINE 19: code-mo = 1 ^ in C:\wamp\www\gdt\php.php on line 35
Warning: pg_fetch_array() expects parameter 1 to be resource, boolean given in C:\wamp\www\gdt\php.php on line 53
affichage d'un sous-ensemble de mes tables
ça passe pas dans ma base de données,tout le problème se trouve dans la partie select.
affichage d'un sous-ensemble de mes tables
voici le code avec les modifications faites ,je peux dire que cava bcoup mieux mais juska présent j'ai le meme problème,aidez moi à voir ce que ne vas pas:
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
| <!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.\"debut-date\",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 localistion
ON projet.\"code-localisation\" = localisation.\"code-localisation\"
WHERE id-nature = 1
AND id-date = 1
AND code-etat =1
AND code-localisation = 1
AND code-mo = 1") ;
?>
<!-- En-tete du tableau -->
<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>
<?php
// utilisation de la boucle tant que
while($infos = pg_fetch_array($sql)) {
// affichage des resultats
echo"<tr>";//ligne du tableau
echo "<td>".$infos['id-projet']."</td>";
echo "<td>".$infos['nom-projet']."</td>";
echo "<td>".$infos['code-mo']."</td>";
echo "<td>".$infos['resultat-projet']."</td>";
echo "<td>".$infos['montant-projet']."</td>";
echo "<td>".$infos['code-localisation']."</td>";
echo "<td>".$infos['id-nature']."</td>";
echo "<td>".$infos['id-date']."</td>";
echo "<td>".$infos['code-etat']."</td>";
echo"</tr>"; //fermeture de la ligne
} //fermeture du tant que
?>
</table> <!--fermeture du tableau-->
<?php pg_close($dbconn);
?>
</body>
</html> |
affichage d'un sous-ensemble de mes tables
j'ai tjour le meme problème avoir modifier la partie where comme tu me la dis
affichage d'un sous ensemble des mes tables
j'ai toujours le meme problème je sai plus quoi faire en meme temps je voudrais injecter un compteur qui incrementeraient les differents identifiants(id-projet,id-nature,id-date,code-mo,code-localisation).regardez le nouveau code pour moi si il contien pas d'erreur
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
| <!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.\"debut-date\",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 localistion
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 -->
<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>
<?php
// utilisation de la boucle tant que
while($infos = pg_fetch_array($sql)) {
// affichage des resultats
echo"<tr>";//ligne du tableau
echo "<td>".$infos['id-projet']."</td>";
echo "<td>".$infos['nom-projet']."</td>";
echo "<td>".$infos['code-mo']."</td>";
echo "<td>".$infos['resultat-projet']."</td>";
echo "<td>".$infos['montant-projet']."</td>";
echo "<td>".$infos['code-localisation']."</td>";
echo "<td>".$infos['id-nature']."</td>";
echo "<td>".$infos['id-date']."</td>";
echo "<td>".$infos['code-etat']."</td>";
echo"</tr>"; //fermeture de la ligne
} //fermeture du tant que
?>
</table> <!--fermeture du tableau-->
<?php pg_close($dbconn);
?>
</body>
</html> |
affichage d'un sou-ensemble de mes tables
que peut-on dans ce cas faire,et j'ai trop compris ce que tu veux dire concernant INNER JOIN localisation,merci d'avance
affichage d'un sous-ensemble de mes tables
je veux dire que j'ai pas trop compris ce que tu voulais dire concernant INNER JOIN localisation
affichage d'un sous-ensemble de mes tables
oui je vois maintenant ,d'accor j'ai noté