IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

PHP & Base de données Discussion :

Affichage du contenu d'une table


Sujet :

PHP & Base de données

  1. #1
    Nouveau membre du Club
    Profil pro
    Inscrit en
    Novembre 2011
    Messages
    37
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Novembre 2011
    Messages : 37
    Points : 27
    Points
    27
    Par défaut Affichage du contenu d'une table
    Bonjour,

    Je débute en Php, php jquery Mysql


    Je tente de realiser une petite application en Php (en utilisant jquery datatable) afin de gerer une liste d'employes mais je n'arrive pas obtenir ce que je veux avec ma page "liste_emplyes" dont voici le code :

    Sur le serveur, j'ai un dossier qui contient les dossiers (js, images, css, admin) et dans le dossier js j'ai
    jquery-1.8.0.min.js
    jquery.dataTables.js
    jquery-ui-1.8.23.custom.min.js


    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
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
     
    <?php require_once('Connections/ma_connection.php'); ?>
     
    <?php require_once('security.php'); ?>
     
    <?php
    if (!function_exists("GetSQLValueString")) {
    function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
    {
      if (PHP_VERSION < 6) {
        $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
      }
     
      $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
     
      switch ($theType) {
        case "text":
          $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
          break;    
        case "long":
        case "int":
          $theValue = ($theValue != "") ? intval($theValue) : "NULL";
          break;
        case "double":
          $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
          break;
        case "date":
          $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
          break;
        case "defined":
          $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
          break;
      }
      return $theValue;
    }
    }
     
    mysql_select_db($database_ma_connection, $ma_connection);
    $query_RsListe = "SELECT * FROM employes2";
    $RsListe = mysql_query($query_RsListe, $ma_connection) or die(mysql_error());
    $row_RsListe = mysql_fetch_assoc($RsListe);
    $totalRows_RsListe = mysql_num_rows($RsListe);
    ?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <title>Liste des employés</title>
      <link href="../css/style.css" rel="stylesheet" type="text/css" />
     
      <link href="../css/style.css" rel="stylesheet" type="text/css" />
    <link href="../css/cupertino/jquery-ui-1.8.23.custom.css" rel="stylesheet" type="text/css" />
    <script type="text/javascript" src="../js/jquery-1.8.0.min.js"></script>
    <script type="text/javascript" src="../js/jquery.dataTables.js"></script>
    <script type="text/javascript" src="../js/jquery-ui-1.8.23.custom.min.js"></script>
     
    <script type="text/javascript" charset="utf-8">
    var oTable;
    $(document).ready(function() {
      $Table = $('#menuTable').dataTable({
        "bJQueryUI": true,
        "sPaginationType": "full_numbers",
        "oLanguage": { "sUrl": "../js/fr_FR.txt" },
        "bAutoWidth": false,
        "aoColumnDefs": [
              { "asSorting": [ "desc" ], "aTargets": [ 0 ] }
          ]
        });
    });
    </script>
     
    </head>
    <body>
    <div id="wrapper">
      <div id="header"><span>ADMINISTRATION DES EMPLOYES</span></div>
      <div id="navigation">
      <a href="liste_employes.php">Liste des employés</a>&nbsp;|&nbsp;<a href="ajout_employes.php">Ajouter un employés</a>&nbsp;|&nbsp;<a href="logout.php">D&eacute;connexion</a>
    </div> 
    <div id="container">
      <p id="ptitle">Liste des employés</p>
     
     
    <table width="100%" border="0" cellpadding="0" cellspacing="0" class="display" id="menuTable">
    <thead>
      <tr>
      <th>ID</th>
      <th>Matricule</th>
      <th>Nom</th>
      <th>Service</th>
      <th>Poste</th>
      <th>Actions</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <?php do { ?>
          <td><?php echo $row_RsListe['id']; ?></td>
          <td><?php echo $row_RsListe['MAT']; ?></td>
          <td><?php echo $row_RsListe['NOM']; ?></td>
          <td><?php echo $row_RsListe['SRV']; ?></td>
          <td><?php echo $row_RsListe['POSTE']; ?></td>
          <td align="center"><img src="../images/edit.gif" width="16" height="16" alt="Edition" />&nbsp;<img src="../images/delete.gif" width="16" height="16" alt="Supprimer" /></td>
          <?php } while ($row_RsListe = mysql_fetch_assoc($RsListe)); ?>
      </tr>
    </tbody>
    <tfoot>
      <tr><th colspan="6">&nbsp;</th></tr>
    </tfoot>
    </table>
     
     
    </div>
    <div id="footer">
      <p>d&eacute;veloppement</p>
    </div>
    </div>
    </body>
    </html>
    <?php
    mysql_free_result($RsListe);
    ?>
    Je souhaiterais afficher le contenu d'une table (liste d'employes : id, nom, poste, ... avec utilisation de jquery datatable pour avoir un tableau avec des entete de colones avec des petites fleches permettant le classa*ment croissant et decroissant) or le tableau n'(affiche pas les fleches et il affiche une seule ligne sur laquel se succede l'ensemble des données de la table a la place d'une ligne par enregistrement.

    Quelqu'un aurait il une idée, une remarque ? SVP Merci

    Bonne journée

    Raphael

  2. #2
    Modérateur
    Avatar de sabotage
    Homme Profil pro
    Inscrit en
    Juillet 2005
    Messages
    29 208
    Détails du profil
    Informations personnelles :
    Sexe : Homme

    Informations forums :
    Inscription : Juillet 2005
    Messages : 29 208
    Points : 44 155
    Points
    44 155
    Par défaut
    Les <tr>, qui representent une ligne du tableau, vont à l'intérieur de ta boucle

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    <?php
    while ($row_RsListe = mysql_fetch_assoc($RsListe) {
       echo '<tr>
          <td>' . $row_RsListe['id'] . '</td>
          <td>' . $row_RsListe['MAT'] . '</td>
          <td>' . $row_RsListe['NOM'] . '</td>
          <td>' . $row_RsListe['SRV'] . '</td>
          <td>' . $row_RsListe['POSTE'] . '</td>
          <td align="center"><img src="../images/edit.gif" width="16" height="16" alt="Edition" />&nbsp;<img src="../images/delete.gif" width="16" height="16" alt="Supprimer" /></td>
       </tr>';
     }
    ?>
    Il faut retirer ton premier mysql_fetch_assoc() perdu en ligne 41.
    N'oubliez pas de consulter les FAQ PHP et les cours et tutoriels PHP

  3. #3
    Nouveau membre du Club
    Profil pro
    Inscrit en
    Novembre 2011
    Messages
    37
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Novembre 2011
    Messages : 37
    Points : 27
    Points
    27
    Par défaut Pb de code
    Bonjour,

    Merci pour cette reponse.

    Maintenant dans mon tableau j'ai mes differentes lignes (differents enregistrement mais il me manque les petits icones dans les entetes de colones et les icones en fin de lignes pour pouvoir modifier et supprimer l'enregistrement (or normalement c'est compris dans datatable ? et là j'ai le mot qui est inscrit))

    Voici mon code actuel :

    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
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
     
    <?php require_once('Connections/ma_connection.php'); ?>
     
    <?php require_once('security.php'); ?>
     
    <?php
    if (!function_exists("GetSQLValueString")) {
    function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
    {
      if (PHP_VERSION < 6) {
        $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
      }
     
      $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
     
      switch ($theType) {
        case "text":
          $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
          break;    
        case "long":
        case "int":
          $theValue = ($theValue != "") ? intval($theValue) : "NULL";
          break;
        case "double":
          $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
          break;
        case "date":
          $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
          break;
        case "defined":
          $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
          break;
      }
      return $theValue;
    }
    }
     
    mysql_select_db($database_ma_connection, $ma_connection);
    $query_RsListe = "SELECT * FROM employes2";
    $RsListe = mysql_query($query_RsListe, $ma_connection) or die(mysql_error());
    $totalRows_RsListe = mysql_num_rows($RsListe);
    ?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <title>Liste des employés</title>
      <link href="../css/style.css" rel="stylesheet" type="text/css" />
     
      <link href="../css/style.css" rel="stylesheet" type="text/css" />
    <link href="../css/cupertino/jquery-ui-1.8.23.custom.css" rel="stylesheet" type="text/css" />
    <script type="text/javascript" src="../js/jquery-1.8.0.min.js"></script>
    <script type="text/javascript" src="../js/jquery.dataTables.js"></script>
    <script type="text/javascript" src="../js/jquery-ui-1.8.23.custom.min.js"></script>
     
    <script type="text/javascript" charset="utf-8">
    var oTable;
    $(document).ready(function() {
      $Table = $('#menuTable').dataTable({
        "bJQueryUI": true,
        "sPaginationType": "full_numbers",
        "oLanguage": { "sUrl": "../js/fr_FR.txt" },
        "bAutoWidth": false,
        "aoColumnDefs": [
              { "asSorting": [ "desc" ], "aTargets": [ 0 ] }
          ]
        });
    });
    </script>
     
    </head>
    <body>
    <div id="wrapper">
      <div id="header"><span>ADMINISTRATION DES EMPLOYES</span></div>
      <div id="navigation">
      <a href="liste_employes.php">Liste des employés</a>&nbsp;|&nbsp;<a href="ajout_employes.php">Ajouter un employés</a>&nbsp;|&nbsp;<a href="logout.php">D&eacute;connexion</a>
    </div> 
    <div id="container">
      <p id="ptitle">Liste des employés</p>
     
     
    <table width="100%" border="0" cellpadding="0" cellspacing="0" class="display" id="menuTable">
    <thead>
      <tr>
      <th>ID</th>
      <th>Matricule</th>
      <th>Nom</th>
      <th>Service</th>
      <th>Poste</th>
      <th>Actions</th>
      </tr>
    </thead>
    <tbody>
     
       <?php
    while ($row_RsListe = mysql_fetch_assoc($RsListe)) {
       echo '<tr>
          <td>' . $row_RsListe['id'] . '</td>
          <td>' . $row_RsListe['MAT'] . '</td>
          <td>' . $row_RsListe['NOM'] . '</td>
          <td>' . $row_RsListe['SRV'] . '</td>
          <td>' . $row_RsListe['POSTE'] . '</td>
          <td align="center"><img src="../images/edit.gif" width="16" height="16" alt="Edition" />&nbsp;<img src="../images/delete.gif" width="16" height="16" alt="Supprimer" /></td>
       </tr>';
     }
    ?>
     
    </tbody>
    <tfoot>
      <tr><th colspan="6">&nbsp;</th></tr>
    </tfoot>
    </table>
     
     
    </div>
    <div id="footer">
      <p>d&eacute;veloppement</p>
    </div>
    </div>
    </body>
    </html>
    <?php
    mysql_free_result($RsListe);
    ?>
    Auriez vous une autre idee ? Svp merci

    @+

    Raphaël
    Fichiers attachés Fichiers attachés

  4. #4
    Modérateur
    Avatar de sabotage
    Homme Profil pro
    Inscrit en
    Juillet 2005
    Messages
    29 208
    Détails du profil
    Informations personnelles :
    Sexe : Homme

    Informations forums :
    Inscription : Juillet 2005
    Messages : 29 208
    Points : 44 155
    Points
    44 155
    Par défaut
    Il doit y avoir un problème avec le chemin vers le fichier image.
    regarde ta source HTML.
    N'oubliez pas de consulter les FAQ PHP et les cours et tutoriels PHP

Discussions similaires

  1. Affichage du contenu d'une table interne
    Par soufiane669 dans le forum SAP
    Réponses: 5
    Dernier message: 17/05/2011, 15h24
  2. Réponses: 8
    Dernier message: 23/07/2010, 10h42
  3. [MySQL] affichage du contenu d'une table
    Par danièle100 dans le forum PHP & Base de données
    Réponses: 4
    Dernier message: 08/04/2010, 11h20
  4. Réponses: 2
    Dernier message: 09/11/2006, 09h59
  5. Lister le contenu d'une table sans connaitre ses champs
    Par Google.be dans le forum PostgreSQL
    Réponses: 9
    Dernier message: 30/03/2004, 15h23

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo