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 :

recuperation des données


Sujet :

PHP & Base de données

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre actif
    Homme Profil pro
    Étudiant
    Inscrit en
    Avril 2011
    Messages
    65
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Tunisie

    Informations professionnelles :
    Activité : Étudiant
    Secteur : High Tech - Opérateur de télécommunications

    Informations forums :
    Inscription : Avril 2011
    Messages : 65
    Par défaut recuperation des données
    bonjours ,,,

    je suis debutant en programmation php, et je cherche un coup de main intelligent. je suis entrain de faire mon premier projet..
    en faite, j'ai un scripte php dans dont lequel j'ai enrigistré des donné dans un tableau (find2.php) , je voudrai recuperer ces meme données dans un autre page (modifier.php)
    et merci d'avance pour votre comprehension
    voici la partie de code (find2.php) avec $tab[0],$tab[1],$tab[2],$tab[4]...et sont les donné recuperé
    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
     
      $sql="select * from pc where n_serie='$sn' ";
    	   $rs=mysql_query("$sql");
    	   $i=1;
    	   $query = "SELECT count(id) from pc where  n_serie='$sn' ";
           $result = mysql_query($query) or die (mysql_error());
           $resultat=mysql_fetch_row($result);
           echo "nbre est :       $resultat[0]";
    	   echo "<br />";
    	   echo "<br />";
    	   while($tab=mysql_fetch_array($rs))
    	   { 
    echo "<tr>";
             echo "<td valign=top><p class=text2> $tab[0]</td>";
    	     echo "<td valign=top><p class=text2> $tab[1]</td>";
    		 echo "<td valign=top><p class=text2> $tab[11]</td>";
    		 echo "<td valign=top><p class=text2> $tab[12]</td>";
    	     echo "<td valign=top><p class=text2> $tab[3]</td>";
    	     echo "<td valign=top><p class=text2> $tab[4]</td>";
    	     echo "<td valign=top><p class=text2> $tab[5]</td>";
    	     echo "<td valign=top><p class=text2> $tab[6]</td>";
    	     echo "<td valign=top><p class=text2> $tab[8]</td>";
    	     echo "<td valign=top><p class=text2> $tab[10]</td>";
    		 }
    		 ?>
    et pour la page" modifier.php" ,voici la partie correspondant..
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
     
    <tr><td width="128"><span class="Style1"> Nom :</span></td> <td><input name="nom" value="<? echo $tab[3]; ?>"><td></td></tr>
    		 <tr><td><span class="Style1"> Prénom :</span></td> <td><input name="pre" value="<? echo $tab[4]; ?>"></td></tr>
    		 <tr><td><span class="Style1"> Matricule :</span></td> <td><input name="matr" value="<? echo $tab[5]; ?>"></td><td></td></tr>
    		 <tr><td><span class="Style1"> Services :</span></td> <td><input name="serv" value="<? echo $tab[6]; ?>"></td><td></td></tr>
    		 </td></tr>
    donc je voudrai avoir les meme $tab[i]..dans les deux pages

  2. #2
    Membre chevronné
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Avril 2011
    Messages
    271
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Italie

    Informations professionnelles :
    Activité : Développeur informatique
    Secteur : High Tech - Produits et services télécom et Internet

    Informations forums :
    Inscription : Avril 2011
    Messages : 271
    Par défaut
    La partie commune entre les deux script php tu la met dans un fichier outils.php et tu ajoute include "outils.php"; avant l'appel

    outils.php
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    function pc_n_serie($sn, &$nb, &$rs){
    $sql="select * from pc where n_serie='$sn' ";
    $rs=mysql_query("$sql") or die (mysql_error());
    $query = "SELECT count(id) from pc where  n_serie='$sn' ";
    $result = mysql_query($query) or die (mysql_error());
    $resultat=mysql_fetch_row($result);
    $nb=$resultat[0];
    }
    find2.php
    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
    include "outils.php";
     
    pc_n_serie($sn, $nb, $rs);
    echo "nbre est :       $nb";
    echo "<br />";
    echo "<br />";
     
    while($tab=mysql_fetch_array($rs)) { 
    echo "<tr>";
    echo "<td valign=top><p class=text2> $tab[0]</td>";
    echo "<td valign=top><p class=text2> $tab[1]</td>";
    echo "<td valign=top><p class=text2> $tab[11]</td>";
    echo "<td valign=top><p class=text2> $tab[12]</td>";
    echo "<td valign=top><p class=text2> $tab[3]</td>";
    echo "<td valign=top><p class=text2> $tab[4]</td>";
    echo "<td valign=top><p class=text2> $tab[5]</td>";
    echo "<td valign=top><p class=text2> $tab[6]</td>";
    echo "<td valign=top><p class=text2> $tab[8]</td>";
    echo "<td valign=top><p class=text2> $tab[10]</td>";
    echo "</tr>";
    }
    modifier.php
    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
    <?php
    include "outils.php";
     
    pc_n_serie($sn, $nb, $rs);
    while($tab=mysql_fetch_array($rs)) { 
    ?>
    <tr>
    <td width="128"><span class="Style1"> Nom :</span></td> 
    <td><input name="nom" value="<?php echo $tab[3]; ?>"></td>
    </tr>
     
    <tr>
    <td><span class="Style1"> Prénom :</span></td> 
    <td><input name="pre" value="<?php echo $tab[4]; ?>"></td>
    </tr>
     
    <tr>
    <td><span class="Style1"> Matricule :</span></td> 
    <td><input name="matr" value="<?php echo $tab[5]; ?>"></td>
    </tr>
     
    <tr>
    <td><span class="Style1"> Services :</span></td> 
    <td><input name="serv" value="<?php echo $tab[6]; ?>"></td>
    </tr>
     
    <?php
    }
    ?>

  3. #3
    Membre averti
    Homme Profil pro
    Étudiant
    Inscrit en
    Juillet 2011
    Messages
    23
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Tunisie

    Informations professionnelles :
    Activité : Étudiant
    Secteur : High Tech - Opérateur de télécommunications

    Informations forums :
    Inscription : Juillet 2011
    Messages : 23
    Par défaut
    bonjours ,

    merci beaucoup ,, j'ai fait,,mais j'ai obtient des donné different ,et il apparait un erreur
    Undefined index: $sn ..
    notez bien que j'ai mis au debut de code:
    dans l'attente....

  4. #4
    Membre chevronné
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Avril 2011
    Messages
    271
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Italie

    Informations professionnelles :
    Activité : Développeur informatique
    Secteur : High Tech - Produits et services télécom et Internet

    Informations forums :
    Inscription : Avril 2011
    Messages : 271
    Par défaut
    Le probleme viens surement de ton formulaire FORM
    il doit ressembler a ceci :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    <form id="ma_form" name="ma_form" action="find2.php" method="post" >
    ...
    <input type="text" name="sn" id="sn" size="70" class="inputbox"  />
    ...
    </form>

  5. #5
    Membre actif
    Homme Profil pro
    Étudiant
    Inscrit en
    Avril 2011
    Messages
    65
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Tunisie

    Informations professionnelles :
    Activité : Étudiant
    Secteur : High Tech - Opérateur de télécommunications

    Informations forums :
    Inscription : Avril 2011
    Messages : 65
    Par défaut
    bnjours

    merci beaucoup,,,

    mais désolé je ne comprend pas ou je peut modifier la forme,,
    SVP , pouvez vous m'aidez un peut plus,,,
    voici ma forme,,,
    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
     
    <?php
      include ("outils.php");
     
          pc_n_serie($sn, $nb, $rs);
          while($tab=mysql_fetch_array($rs)) { 
    ?>
    		  <tr>
    		    <td COLSPAN="6">&nbsp;</td>
    		   </tr>
          </table>
        </td>
    </tr>
     <td  valign="top"><hr>
    	 <table width="966" height="227"  BORDER="0" CELLPADDING="0" CELLSPACING="0" bordercolor="#BDE7F7">
    	   <tr>
    	     <th height="33" ><p align="left" class=text2>Réaffectation de PC </th>
    	   </tr>
    	   <tr>
    	     <td height="125" align="center">
    		 <table width="335" height="105">
    		 <form name="f2" action="affect2.php" method="post">
    		 <input type="hidden" value="<?php echo $id; ?>" name="id">
    		<tr>
        <td width="128"><span class="Style1"> Nom :</span></td> 
        <td><input name="nom" value="<?php echo $tab[3]; ?>"></td>
        </tr>
     
       <tr>
       <td><span class="Style1"> Prénom :</span></td> 
       <td><input name="pre" value="<?php echo $tab[4]; ?>"></td>
        </tr>
     
       <tr>
       <td><span class="Style1"> Matricule :</span></td> 
       <td><input name="matr" value="<?php echo $tab[5]; ?>"></td>
       </tr>
     
       <tr>
       <td><span class="Style1"> Services :</span></td> 
       <td><input name="serv" value="<?php echo $tab[6]; ?>"></td>
       </tr>
      <tr><td><span class="Style1"> Date : </span></td> <td><?php echo $d; ?></td></tr>
      <tr>
      <label></label></td></tr>
      <tr><td height="52"><input type="submit" value="Valider" ></td>
      <td><input type="reset" value="Annuler"></td></tr>
    </form>

  6. #6
    Membre chevronné
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Avril 2011
    Messages
    271
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Italie

    Informations professionnelles :
    Activité : Développeur informatique
    Secteur : High Tech - Produits et services télécom et Internet

    Informations forums :
    Inscription : Avril 2011
    Messages : 271
    Par défaut
    Avant d'appeler les script php find2.php ou modifier.php, la variable $sn doit avoir une valeur, tu as dit que tu la recupere a travers un POST mais dans quel formulaire? le formulaire "f2" que tu donne ne fait aucune reference a "sn"!

Discussions similaires

  1. recuperer des données calculé
    Par mael94420 dans le forum Langage SQL
    Réponses: 4
    Dernier message: 06/01/2006, 13h12
  2. Réponses: 2
    Dernier message: 22/11/2005, 22h09
  3. [VB.NET] Recuperer des données ds un fichier
    Par Aspic dans le forum VB.NET
    Réponses: 2
    Dernier message: 03/11/2005, 09h31
  4. Recuperer des données d'access
    Par Lucier dans le forum MFC
    Réponses: 18
    Dernier message: 25/11/2004, 10h29
  5. Réponses: 3
    Dernier message: 22/02/2004, 20h09

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