Bonjour, je vous précise que je suis débutant en php/mysql, mon problème est que je ne sais pas comment afficher les enregistrements récupérés grâce a une procédure stockée sous forme de table html, par exemple j'aimerais afficher pour chaque ligne <tr><td>info</td> <td>info2</td> <td>info3</td> etc .
Le resultat affiché dans la page html est :
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
22
23
24
25
26 //Récupération du paramètre de la procédure stockée $Param = $_POST['IDPerson']; // Connexion à la base $mysqli = new mysqli("localhost", "root", "", "lfct"); if ($mysqli->connect_errno) { echo "Echec lors de la connexion à MySQL: (" . $mysqli->connect_errno . ") " . $mysqli->connect_error;} //Appel de la procédure stockée if (!$mysqli->multi_query("CALL Stats('$Param')")) { echo "Echec lors de l'appel à CALL : (" . $mysqli->errno . ") " . $mysqli->error;} do { if ($res = $mysqli->store_result()) { printf("---\n"); var_dump($res->fetch_all()); $res->free();} else { if ($mysqli->errno) { echo "Echec de STORE : (" . $mysqli->errno . ") " . $mysqli->error; } } } while ($mysqli->more_results() && $mysqli->next_result()); ?>
---
array (size=5)
0 =>
array (size=13)
0 => string '5005' (length=4)
1 => string '2012-09-23' (length=10)
2 => string 'FIL' (length=25)
3 => string 'LOC' (length=4)
4 => string '2' (length=1)
5 => string '0' (length=1)
6 => string '10' (length=2)
7 => string '90' (length=2)
8 => string '1017' (length=4)
9 => null
10 => null
11 => null
12 => null
1 =>
array (size=13)
0 => string '5000' (length=4)
1 => string '2012-10-07' (length=10)
2 => string 'FILE' (length=16)
3 => string 'LOC' (length=4)
4 => string '2' (length=1)
5 => string '4' (length=1)
6 => string '10' (length=2)
7 => string '90' (length=2)
8 => string '1017' (length=4)
9 => null
10 => null
11 => null
12 => null
2 =>
array (size=13)
0 => string '4998' (length=4)
1 => string '2012-10-21' (length=10)
2 => string 'LONG (length=15)
3 => string 'LOC' (length=4)
4 => string '1' (length=1)
5 => string '3' (length=1)
6 => string '10' (length=2)
7 => string '90' (length=2)
8 => string '1017' (length=4)
9 => null
10 => string '2' (length=1)
11 => null
12 => null
avec une requête je m'en sort en faisant cela :
Est il possible de faire la même chose avec ma procédure stockée ?
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
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36 mysql_select_db($database_ConnexionMYSQL, $ConnexionMYSQL); $query_ts = "MON SELECT"; $ts = mysql_query($query_RsTableau, $ConnexionMYSQL) or die(mysql_error()); $row_ts = mysql_fetch_assoc($RsTableau); $totalRows_ts = mysql_num_rows($ts); <table> <tr> <td>Date</th> <td>Dm</th> <td>Ex</th> <td>Rés</th> <td>Num</th> <td>Mn</th> <td>Bt</th> <td>Dc</th> <td>Jn</th> <td>Rg</th> </tr> <?php do { ?> <tr> <td><?php echo $row_ts['Champ1']; ?></td> <td><?php echo $row_ts['Champ2']; ?></td> <td><?php echo $row_ts['Champ3']; ?></td> <td><?php echo $row_ts['Champ4']; ?></td> <td><?php echo $row_ts['Champ5']; ?></td> <td><?php echo $row_ts['Champ5']; ?></td> <td><?php echo $row_ts['Champ6']; ?></td> <td><?php echo $row_ts['Champ7']; ?></td> <td><?php echo $row_ts['Champ8']; ?></td> <td><?php echo $row_ts['Champ9']; ?></td> <td><?php echo $row_ts['Champ10']; ?></td> </tr> <?php } while ($row_ts = mysql_fetch_assoc($ts)); ?> </table>
Ce que je préférais car habitué et je comprend a peu prés ce que je fais
Sinon comment modifié le code précédent pour en faire un tableau html ?
Merci waouh j'ai tartiné la
Partager