Php et les tableaux html

après avoir cherché sur le net et bossé sur les tutoriels je me suis tombé sur cette cas j'ai une table map qui contient ensemble des colons tel que :

MeasurementDate MeasurementTime mea_object Oper_Reque Pos_Respo

et je veux recupere ces donnes atravere le php de facon d'etre organiser comme suit :

Date/ Oparation | UpdateLocation | ProvideRoamingNumber |
2016-05-23|20:00|Oper_Reque/Pos_Respo |Oper_Reque/Pos_Respo
2016-05-23|21:00|Oper_Reque/Pos_Respo |Oper_Reque/Pos_Respo
2016-05-24|20:00|Oper_Reque/Pos_Respo |Oper_Reque/Pos_Respo

1 réponse

  1. voici mon essay

    <?php
    //Fichier de connexion à la bdd : cnxBdd.php
    try{
    $bdd = new PDO("mysql:host=localhost;dbname=application;charset=UTF8", 'root', '');
    $bdd->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); //pour activer l'affichage des erreurs pdo
    } catch(PDOException $e){
    echo 'ERROR: ' . $e->getMessage();
    }
    ?>

    <?php
    //affichage des erreurs php
    error_reporting(E_ALL);

    //connexion à la BDD
    require_once "cnxBdd.php";

    //requête
    try{
    // On récupère tout le contenu de la table jeux_video
    $reponse = $bdd->query('SELECT * FROM map ');
    }catch(Exception $e){
    //en cas d'erreur dans la requete
    echo "erreur : ".$e->getMessage();
    }

    //fin de la partie PHP.. on passe au HTML
    ?>
    <html>
    <head>

    <link rel="stylesheet" type="text/css" media="screen" href="css/accueil.css">
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    </head>
    <body>
    <div id="top"></div>

    <table width="150px" id="tableau" height="150" CELLSPACING="2" CELLPADDING="2" border="2">
    <thead>
    <tr>
    <th scope="col">Date/Map Oparation</th>
    <th scope="col">Le temps de l'operation</th>
    <th scope="col">UpdateLocation</th>
    <th scope="col">ProvideRoamingNumber</th>
    <th scope="col">AuthenticationFailureReport</th>
    <th scope="col">UpdateGPRSLocation</th>
    <th scope="col">SendRoutingInformationforShortMessage</th>
    <th scope="col">ReadyforShortMessage</th>
    <th scope="col">AnyTimeInterrogation</th>
    <th scope="col">CancelLocation</th>
    <th scope="col">InsertSubscriberData</th>
    <th scope="col">SendRoutingInformation</th>
    <th scope="col">SendRoutingInformationforGPRS</th>
    <th scope="col">SendAuthenticationInformation</th>
    <th scope="col">ProvideSubscriberInformation</th>

    </tr>
    </thead>
    <tbody>
    <?php
    $datePrecedente = "";
    $timprecedente="";

    while ($R = $reponse->fetch()) {
    $date = $R['MeasurementDate'];
    $tim= $R['MeasurementTime'];

    if($datePrecedente ="" || $datePrecedente != $date || $timprecedente="" || $timprecedente!=$tim){
    if($datePrecedente !=""){
    //on ferme la ligne précédente si il y en a une
    echo "</tr>";
    }
    //on créé la nouvelle ligne

    echo "<tr>";
    echo "<th>".$date."</th><th>".$tim."</th>";
    }
    $pou=(int)($R['OperationRequests']/$R['PositiveResponses'])*100;

    if($R['MAP_measurement_object']=="UpdateLocation"){

    echo "<td>".$R['MAP_measurement_object'].": ".$pou."%"."</td>";

    $datePrecedente = $date ; // on place la date dans la variable datePrecedente
    $timprecedente=$tim;

    }

    if($R['MAP_measurement_object']=="ProvideRoamingNumber"){

    echo "<td ><td>".$R['MAP_measurement_object'].": ".$pou."%"."</td></td>";

    $datePrecedente = $date ; // on place la date dans la variable datePrecedente
    $timprecedente=$tim;

    }

    if($R['MAP_measurement_object']=="AuthenticationFailureReport"){

    echo "<td><td ><td >".$R['MAP_measurement_object'].": ".$pou."%"."</td ></td></td>";

    $datePrecedente = $date ; // on place la date dans la variable datePrecedente
    $timprecedente=$tim;

    }

    if($R['MAP_measurement_object']=="UpdateGPRSLocation"){

    echo "<td><td><td ><td >".$R['MAP_measurement_object'].": ".$pou."%"."</td></td ></td></td>";

    $datePrecedente = $date ; // on place la date dans la variable datePrecedente
    $timprecedente=$tim;

    }

    if($R['MAP_measurement_object']=="SendRoutingInformationforShortMessage"){

    echo "<td><td><td><td ><td >".$R['MAP_measurement_object'].": ".$pou."%"."</td></td></td ></td></td>";

    $datePrecedente = $date ; // on place la date dans la variable datePrecedente
    $timprecedente=$tim;

    }

    if($R['MAP_measurement_object']=="ReadyforShortMessage"){

    echo "<td><td><td><td><td ><td >".$R['MAP_measurement_object'].": ".$pou."%"."</td></td></td></td ></td></td>";

    $datePrecedente = $date ; // on place la date dans la variable datePrecedente
    $timprecedente=$tim;

    }

    if($R['MAP_measurement_object']=="AnyTimeInterrogation"){

    echo "<td><td><td><td><td><td ><td >".$R['MAP_measurement_object'].": ".$pou."%"."</td></td></td></td></td ></td></td>";

    $datePrecedente = $date ; // on place la date dans la variable datePrecedente
    $timprecedente=$tim;

    }

    if($R['MAP_measurement_object']=="CancelLocation"){

    echo "<td><td><td><td><td><td><td ><td >".$R['MAP_measurement_object'].": ".$pou."%"."</td></td></td></td></td></td ></td></td>";

    $datePrecedente = $date ; // on place la date dans la variable datePrecedente
    $timprecedente=$tim;

    }

    if($R['MAP_measurement_object']=="InsertSubscriberData"){

    echo "<td/><td/><td/><td/><td/><td/><td/><td/><td >".$R['MAP_measurement_object'].": ".$pou."%"."</td>";

    $datePrecedente = $date ; // on place la date dans la variable datePrecedente
    $timprecedente=$tim;

    }

    }

    //on ferme la dernière ligne du tableau
    echo "</tr>";
    $reponse->closeCursor(); // Termine le traitement de la requête
    ?>
    </tbody>

    </table>

    </body>
    </html>