Bonjour!

J'ai créé ma BD et j'ai réussi à l'afficher sur page via ce 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
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
 
<?php //Connection avec la BDD.
    mysql_connect("localhost", "root", "");
    mysql_select_db("cisco_sante");
    $reponse = mysql_query("SELECT * FROM patients");
    ?>
 
    <table width="800">
            <tr>
                <th colspan="5" style="border-radius: 5px; background-color: #079839; height: 30px;">Date</th>
                <th colspan="5" style="border-radius: 5px; background-color: #079839; height: 30px;">IPM</th>
                <th colspan="5" style="border-radius: 5px; background-color: #079839; height: 30px;">Numéro</th>
                <th colspan="5" style="border-radius: 5px; background-color: #079839; height: 30px;">Nom</th>
                <th colspan="5" style="border-radius: 5px; background-color: #079839; height: 30px;">C</th>
                <th colspan="5" style="border-radius: 5px; background-color: #079839; height: 30px;">K</th>
                <th colspan="5" style="border-radius: 5px; background-color: #079839; height: 30px;">KR</th>
                <th colspan="5" style="border-radius: 5px; background-color: #079839; height: 30px;">V</th>
                <th colspan="5" style="border-radius: 5px; background-color: #079839; height: 30px;">Montant</th>
            </tr>
        <?php //On affiche les lignes du tableau une à une à l'aide d'une boucle
        while($donnees = mysql_fetch_array($reponse))
        {
        ?>
<tr bgcolor="#CCCCCC" align="center">
    <td colspan="5" style="border-radius: 5px" scope="col"><?php echo $donnees['date'];?></td>
    <td colspan="5" style="border-radius: 5px" scope="col"><?php echo $donnees['ipm'];?></td>
    <td colspan="5" style="border-radius: 5px" scope="col"><?php echo $donnees['numero'];?></td>
    <td colspan="5" style="border-radius: 5px" scope="col"><?php echo $donnees['nom'];?></td>
    <td colspan="5" style="border-radius: 5px" scope="col"><?php echo $donnees['c'];?></td>
    <td colspan="5" style="border-radius: 5px" scope="col"><?php echo $donnees['k'];?></td>
    <td colspan="5" style="border-radius: 5px" scope="col"><?php echo $donnees['kr'];?></td>
    <td colspan="5" style="border-radius: 5px" scope="col"><?php echo $donnees['v'];?></td>
    <td colspan="5" style="border-radius: 5px" scope="col"><?php echo $donnees['montant'];?></td>
</tr>
        <?php
        } //fin de la boucle, le tableau contient toute la BDD
        mysql_close(); //deconnection de mysql
        ?>
    </table>
et j'aimerai bien savoircomment pourrai-je la somme de chaque "ipm" dans un petit formulaire comme par exemple:

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
<table>
<tr>
    <th scope="col"style="border-radius: 5px; background-color: #079839; height: 30px;">Total AR</th>
    <th scope="col"style="border-radius: 5px; background-color: #079839; height: 30px;">Total CMS</th>
    <th scope="col"style="border-radius: 5px; background-color: #079839; height: 30px;">Total CNART AMREF</th>
</tr>
  <tr bgcolor="#CCCCCC" align="center">
    <td style="border-radius: 5px"> </td>
    <td style="border-radius: 5px"> </td>
    <td style="border-radius: 5px"> </td>
</tr>
</table>
Ce code sql marche bien dans phpmyadmin
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
SELECT SUM( montant ) 
FROM `patients` 
WHERE `ipm`= 'cms';
mais je ne sais pa comment le manipuler avec un formulaire php!
Merci!