Bonjour, bonsoir.

Voila mon problème. J'essais de m'améliorer en programmation PHP (je code avec NEtBEans, et utilise WAMP). J'ai donc créer une Base De Donnée appelé test_ficheur. Elle contient deux table:
Voila la "hierarchie des mes tables et de la BDD:

  • test_ficheur
    • cours
      • Titre
      • Corps
      • Matiere

    • matieres
      • Matiere
      • Prof


J'ai rempli ces table en passant par l'interface:
Voici cours sous forme de tableau:
Titre Corps Matiere
Codage PHP Pour modifier une base de donnée, il faut une requête SQL Developpement
Les dérivés Soit f(x)=3x² alors f'(x)=6x Mathématique

Voici Matieres en tableau:

Matiere Prof
Developpement AA
Mathématique BB

cours.Matiere est un clé etrangère de matieres.Matiere .

Voila mon 1er code:
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
<?php
//$matiere=$_POST['Matiere'];
 
 
$infoBDD="mysql: host=localhost; bddname=test_ficheur";
$connect=new PDO($infoBDD, 'root', '');
$connect->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
 
 
$request="SELECT * FROM `cours` WHERE `matiere`='Mathématique';";
 
$resultat=$connect->query($request);
echo "<table><tr><td>Titre</td><td>Corps</td></tr>";
while ($row =$resultat->fetch(PDO::FETCH_ASSOC))
{
    echo "<tr>";
    echo "<td>{$row['Titre']}</td><td>{$row['Corps']}</td>";
    echo "</tr>";
}
echo "</table>";

Avec ce code cela m'affochait cette erreur:
Nom : erreur.PNG
Affichages : 195
Taille : 30,4 Ko

J'ai résolu cette erreur en changeant la ligne 10:
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
<?php
//$matiere=$_POST['Matiere'];
 
 
$infoBDD="mysql: host=localhost; bddname=test_ficheur";
$connect=new PDO($infoBDD, 'root', '');
$connect->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
 
 
$request="SELECT * FROM `test_ficheur`.`cours` WHERE `matiere`='Mathématique';";
 
 
$resultat=$connect->query($request);
echo "<table><tr><td>Titre</td><td>Corps</td></tr>";
while ($row =$resultat->fetch(PDO::FETCH_ASSOC))
{
    echo "<tr>";
    echo "<td>{$row['Titre']}</td><td>{$row['Corps']}</td>";
    echo "</tr>";
}
echo "</table>";
Pourquoi il trouve la table en rajoutant ca, alors que le nom de ma BDD est donnée dans $infoBDD à la ligne 5 et 6??

En revanche maintenant j'ai un autre problème: la page ne m'affiche rien. Mais rien de rien! Page vierge, pas d'erreur, pas de texte, rien; que du blanc -_- .

Quelqu'un sait pourquoi il n'affiche pas un truc du genre:
Titre Corps
Codage PHP Pour modifier une base de donnée, il faut une requête SQL
Les dérivés Soit f(x)=3x² alors f'(x)=6x

Merci d'avance