Page 1 sur 1

Pb de code Php/jquery/Mysql

Posté : 10 févr. 2014, 11:23
par Raphael3922
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 : Tout sélectionner

<?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

Re: Pb de code Php/jquery/Mysql

Posté : 10 févr. 2014, 12:42
par Raphael3922
Bonjour,
J'ai avancé

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 : Tout sélectionner

<?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 idee ? Svp merci

@+

Raphaël