Bonjour a tous !
Voila j'ai creer une base de donnée :
j'affiche les resultats dans un tableau :
Code php : 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 <? echo " <H1>Creation base de données avec une requete sql <br></H1>"; $f = mysql_connect("localhost","root",""); $req = "Create Database BaseNotesIris"; $ok = mysql_query($req,$f); mysql_select_db("BaseNotesIris"); $req="create Table annee1 ( Trimestre Int(2)unsigned not null , Francais Int(5) unsigned not null , Anglais Int(5) unsigned not null , Economie Int(5) unsigned not null , Math Int(5) unsigned not null , Physique Int(5) unsigned not null , Informatique1 Int(5) unsigned not null , Informatique2 Int(5) unsigned not null , Informatique3 Int(5) unsigned not null , Informatique4 Int(5) unsigned not null , primary key(Trimestre) )"; // primary key(num) $ok=mysql_query($req,$f); mysql_close($f); ?>
Mon souhait serait de recuperer les differentes valeurs de ma base par rapport a la clé pour apres pourvoir utiliser ces variables pour creer un graph avec jpgraph ( mon graph est deja cree ya plus qu'a lui affecter les variables de ma base ! )
Code php : 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 <? /* connexion au serveur */ $f = mysql_connect ("localhost", "root", ""); mysql_select_db ("BaseNotesIris"); $req = "select * from annee1"; $result = mysql_query ($req, $f); $nbLignes = mysql_num_rows ($result); $nbCols = mysql_num_fields ($result); echo "<table border = \"3\">"; echo "<tr> <td>Trimestre </td> <td>Francais </td> <td>Anglais </td> <td>Economie </td> <td>Math </td> <td> Physique </td> <td> Informatique1 </td> <td> Informatique2 </td> <td> Informatique3 </td> <td> Informatique4 </td></tr>"; for ($i=0; $i<2; $i++) { $lig = mysql_fetch_array ($result); echo "<tr>"; for ($j=0; $j<$nbCols; $j++) { echo "<td>"; echo "$lig[$j]" ; echo"</td>"; } echo "</tr>"; } echo "</table>"; mysql_close ($f); ?>
Je pense que la requete devrait etre un truc dans ce genre $req = "select * from annee1 where Trimestre=1";
ps Trimestre est ma clé !
Toute aide est bienvenue
Partager