Probléme datatable

Résolu
bechirmrad Messages postés 37 Date d'inscription   Statut Membre Dernière intervention   -  
bechirmrad Messages postés 37 Date d'inscription   Statut Membre Dernière intervention   -
Bonjour,
j'avais un probléme dans le datatable
il m'affiche que les deux colonnes avec des variables justes .. et le reste sont avec la meme variable

2 réponses

jordane45 Messages postés 38486 Date d'inscription   Statut Modérateur Dernière intervention   4 752
 
Bonjour
Et quel code as tu écris ?
0
bechirmrad Messages postés 37 Date d'inscription   Statut Membre Dernière intervention  
 
<?php
include 'conn.php';

$Fabric = array();
 $Fabr = odbc_exec($conn,$sqlFabr);
 while (odbc_fetch_row($Fabr))
 {
  $idfabr = odbc_result($Fabr,1);
  $Fabric[$idfabr] = odbc_result($Fabr,2);
  $tsuivi = odbc_result($Fabr,3);
  $co = odbc_result($Fabr,4);
  $idclco = odbc_result($Fabr,5);
  $dtdeb = odbc_result($Fabr,6);
  $dtfin = odbc_result($Fabr,7);
  $quan = odbc_result($Fabr,8);
  $idstepof = odbc_result($Fabr,9);
  $rendmoy = odbc_result($Fabr,10);
  $idart = odbc_result($Fabr,11);
  $code = odbc_result($Fabr,12);
  $prix = odbc_result($Fabr,13);
  $artart = odbc_result($Fabr,14);
  $idfam = odbc_result($Fabr,15);
  $idsousfam = odbc_result($Fabr,16);
  $idclart = odbc_result($Fabr,17);
  $coulart = odbc_result($Fabr,18);
  $etape = odbc_result($Fabr,19);
  $couletape = odbc_result($Fabr,20);
  $etat = odbc_result($Fabr,21);
  $process = odbc_result($Fabr,22);
  $gamme = odbc_result($Fabr,23);
  $tpsgamme = odbc_result($Fabr,24);
  $qttelct = odbc_result($Fabr,25);
  $codecl = odbc_result($Fabr,26);
  $cl = odbc_result($Fabr,27);
  $idproc = odbc_result($Fabr,28);
  $prio = odbc_result($Fabr,29);
  $dtexp = odbc_result($Fabr,30);
  $dttissu = odbc_result($Fabr,31);
  $dtfourn= odbc_result($Fabr,32);
  $idchamont = odbc_result($Fabr,33);
  $idtiers = odbc_result($Fabr,34);
  $idclof = odbc_result($Fabr,35);
  $dtexpprev = odbc_result($Fabr,36);
  $etatbloc = odbc_result($Fabr,37);
  $ref = odbc_result($Fabr,38);
 
 }
 
             ?>
        <html>
         <head>
            <link   rel="stylesheet" href="https://cdn.datatables.net/1.10.16/css/jquery.dataTables.min.css">
            <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
            <script src="https://cdn.datatables.net/1.10.16/js/jquery.dataTables.min.js"></script>
            <script>

$(document).ready(function() {
    // Setup - add a text input to each footer cell
    $('#example tfoot th').each( function () {
        var title = $(this).text();
        $(this).html( '<input type="text" placeholder="Search '+title+'" />' );
    } );
 
    // DataTable
    var table = $('#example').DataTable();

 
    // Apply the search
    table.columns().every( function () {
        var that = this;
 
        $( 'input', this.footer() ).on( 'keyup change', function () {
            if ( that.search() !== this.value ) {
                that
                    .search( this.value )
                    .draw();
            }
        } );
    } );
} );

            </script>
        </head>
        <body>
  
  
   
             <table id="example" border="1" width="20%">
                <thead>
    <th>OFabrication_OF</th>
                <th>IDOFabrication</th>
                <th>TypeSuivi</th>
                <th>Commande_CO</th>
                <th>IdClientCommande</th>
                <th>DtDebut</th>
                <th>DtFin</th>
                <th>Quantite</th>
                <th>IDStepOF</th>
                <th>RendementMoyen</th>
                <th>IDArticle</th>
                <th>Code</th>
                <th>Prix</th>
                <th>Article_Ar</th>
                <th>IdFamille</th>
                <th>IdSousFamille</th>
                <th>IdClientArticle</th>
                <th>CouleurArticle</th>
                <th>Etape</th>
                <th>CouleurEtape</th>
                <th>Etat</th>
                <th>Process</th>
                <th>Gamme</th>
                <th>TpsGamme</th>
                <th>QtteLct</th>
                <th>CodeClient</th>
                <th>Client</th>
                <th>IdProcess</th>
                <th>Priorite</th>
                <th>DateExport</th>
                <th>DateTissu</th>
                <th>DateFourniture</th>
                <th>IDChaineMontage</th>
                <th>IDTiers</th>
                <th>IDClientOF</th>
                <th>DateExportPrevue</th>
                <th>EtataBlocage</th>
                <th>Reference</th>
                </thead>
    <tbody>
    
    <?php 
                foreach ($Fabric as $idfabr => $ofabr){ ?>
                <tr>
                    <td align="center"><?php print_r($idfabr)?></td>
                    <td align="center"><?php print_r($ofabr)?></td>
     <td align="center"><?php print_r($tsuivi)?></td>
     <td align="center"><?php print_r($co)?></td>
     <td align="center"><?php print_r($idclco)?></td>
     <td align="center"><?php print_r($dtdeb)?></td>
     <td align="center"><?php print_r($dtfin)?></td>
     <td align="center"><?php print_r($quan)?></td>
     <td align="center"><?php print_r($idstepof)?></td>
     <td align="center"><?php print_r($rendmoy)?></td>
     <td align="center"><?php print_r($idart)?></td>
     <td align="center"><?php print_r($code)?></td>
     <td align="center"><?php print_r($prix)?></td>
     <td align="center"><?php print_r($artart)?></td>
     <td align="center"><?php print_r($idfam)?></td>
     <td align="center"><?php print_r($idsousfam)?></td>
     <td align="center"><?php print_r($idclart)?></td>
     <td align="center"><?php print_r($coulart)?></td>
     <td align="center"><?php print_r($etape)?></td>
     <td align="center"><?php print_r($couletape)?></td>
     <td align="center"><?php print_r($etat)?></td>
     <td align="center"><?php print_r($process)?></td>
     <td align="center"><?php print_r($gamme)?></td>
     <td align="center"><?php print_r($tpsgamme)?></td>
     <td align="center"><?php print_r($qttelct)?></td>
     <td align="center"><?php print_r($codecl)?></td>
     <td align="center"><?php print_r($cl)?></td>
     <td align="center"><?php print_r($idproc)?></td>
     <td align="center"><?php print_r($prio)?></td>
     <td align="center"><?php print_r($dtexp)?></td>
     <td align="center"><?php print_r($dttissu)?></td>
     <td align="center"><?php print_r($dtfourn)?></td>
     <td align="center"><?php print_r($idchamont)?></td>
     <td align="center"><?php print_r($idtiers)?></td>
     <td align="center"><?php print_r($idclof)?></td>
     <td align="center"><?php print_r($dtexpprev)?></td>
     <td align="center"><?php print_r($etatbloc)?></td>
     <td align="center"><?php print_r($ref)?></td>
     
                </tr>
    
    
        <?php  } ?>
    <tfoot>
    <th>OFabrication_OF</th>
                <th>IDOFabrication</th>
                <th>TypeSuivi</th>
                <th>Commande_CO</th>
                <th>IdClientCommande</th>
                <th>DtDebut</th>
                <th>DtFin</th>
                <th>Quantite</th>
                <th>IDStepOF</th>
                <th>RendementMoyen</th>
                <th>IDArticle</th>
                <th>Code</th>
                <th>Prix</th>
                <th>Article_Ar</th>
                <th>IdFamille</th>
                <th>IdSousFamille</th>
                <th>IdClientArticle</th>
                <th>CouleurArticle</th>
                <th>Etape</th>
                <th>CouleurEtape</th>
                <th>Etat</th>
                <th>Process</th>
                <th>Gamme</th>
                <th>TpsGamme</th>
                <th>QtteLct</th>
                <th>CodeClient</th>
                <th>Client</th>
                <th>IdProcess</th>
                <th>Priorite</th>
                <th>DateExport</th>
                <th>DateTissu</th>
                <th>DateFourniture</th>
                <th>IDChaineMontage</th>
                <th>IDTiers</th>
                <th>IDClientOF</th>
                <th>DateExportPrevue</th>
                <th>EtataBlocage</th>
                <th>Reference</th>
                </tfoot>
    </tbody>
   </table>
  </body>
</html>


EDIT : Ajout des balises de code
0
jordane45 Messages postés 38486 Date d'inscription   Statut Modérateur Dernière intervention   4 752
 
Les deux colonnes qui varient sont celles qui sont traitées dans ta boucle
<td align="center"><?php print_r($idfabr)?></td>
                    <td align="center"><?php print_r($ofabr)?></td>

Les autres valeurs... proviennent des variables que tu as défini au début de ton code.... et ne sont pas traitées dans ta boucle...
Normal donc qu'il recopie les mêmes valeurs dans toutes tes lignes de ton tableau.
Sers toi de ta boucle
 while (odbc_fetch_row($Fabr))
pour générer les lignes de ton tableau.
Là... au début de ton code, elle ne sert à rien.


0
bechirmrad Messages postés 37 Date d'inscription   Statut Membre Dernière intervention  
 
Alors que je dois faire ???
0
jordane45 Messages postés 38486 Date d'inscription   Statut Modérateur Dernière intervention   4 752
 
Ben, à la place de ta boucle
 foreach ($Fabric as $idfabr => $ofabr){ ?>

Tu utilises directement la boucle
while (odbc_fetch_row($Fabr))
0
bechirmrad Messages postés 37 Date d'inscription   Statut Membre Dernière intervention  
 
stp un autre problème !! qu'est ce que je dois faire
pour que le tableau se filtre avec un variable en (select option)
0
jordane45 Messages postés 38486 Date d'inscription   Statut Modérateur Dernière intervention   4 752 > bechirmrad Messages postés 37 Date d'inscription   Statut Membre Dernière intervention  
 
Bonjour,
On a coutume ici de ne traiter qu'une seule question par discussion.
Je t'invite donc à mettre ce sujet en RESOLU et à en ouvrir un autre.
Surtout que ta question est plus liée au fonctionnement de datatable et est donc du JAVASCRIPT. (et non du php.... thème de ce forum )
0
bechirmrad Messages postés 37 Date d'inscription   Statut Membre Dernière intervention  
 
ah ok merci
0