Bonjour,
J'ai créé une liste de boutons radios pour afficher différents graphes dans un frame.
Code html : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15 <div id="main"> <input name="radio" type="radio" onclick="iframe.location.href='graphiques/graph1.html'"/><label>Graph.1</label><br /> <input name="radio" type="radio" onclick="iframe.location.href='graphiques/graph2.html'"/><label>Graph.2</label><br /> <input name="radio" type="radio" onclick="iframe.location.href='graphiques/graph3.html'"/><label>Graph.3</label><br /> <input name="radio" type="radio" onclick="iframe.location.href='graphiques/graph4.html'"/><label>Graph.4</label><br /> <input name="radio" type="radio" onclick="iframe.location.href='graphiques/graph5.html'"/><label>Graph.5</label><br /> <input name="radio" type="radio" onclick="iframe.location.href='graphiques/graph6.html'"/><label>Graph.6</label><br /> <input name="radio" type="radio" onclick="iframe.location.href='graphiques/graph7.html'"/><label>Graph.7</label><br /> <input name="radio" type="radio" onclick="iframe.location.href='graphiques/graph8.html'"/><label>Graph.8</label><br /> <input name="radio" type="radio" onclick="iframe.location.href='graphiques/graph9.html'"/><label>Graph.9</label><br /> <input name="radio" type="radio" onclick="iframe.location.href='graphiques/graph10.html'"/><label>Graph.10</label> </div> <iframe name="iframe" id="iframe" scrolling="no" frameborder="0"> </iframe>
Je cherche à ajouter les labels de façon dynamique, à partir d'une liste de champs dans ma base de données.
Est-ce possible avec quelque chose de ce type?
Fichier base.php :
Fichier index.html :
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 <?php $host = "localhost"; $user = "root"; $passwd = ""; $database = "database"; $connect = mysql_connect($host, $user,$passwd); if(!$connect){ die('Erreur de connexion au serveur'); } $select_db = mysql_select_db($database); if(!$select_db){ die('Erreur de connexion à la base'); } ?>
Code html : 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 <div id="main"> <?php require_once('base.php'); $reponse = "SELECT nom_groupe FROM table"; $requete = mysql_query($reponse); $resultat = mysql_fetch_array($requete); $champ = $resultat['nom_groupe']; for ($i = 1; $i <= 10; $i++) { ?> <input name="radio" type="radio" onclick="iframe.location.href='graphiques/graph.html'"/> <label><?php echo $champ[i]; ?></label> </div> <iframe name="iframe" id="iframe" scrolling="no" frameborder="0"> </iframe>
Merci d'avance
Partager