Précédent   Forum des professionnels en informatique > PHP > PHP & SGBD > PHP & MySQL
PHP & MySQL Forum d'entraide sur les fonctions MySQL avec PHP. Avant de poster -> FAQ MySQL, Cours MySQL et Sources MySQL. Pour les questions concernant le moteur MySQL plutôt que les fonctions PHP, merci d'utiliser le forum MySQL.
Partagez cette discussion sur d'autres réseaux sociaux : Viadeo Twitter Google Facebook Digg Delicious MySpace Yahoo
Réponse Proposer ce sujet en actualité
 
Outils de la discussion
Publicité
'
Vieux 06/07/2011, 22h42   #1
 
Homme khmaies guesmi
Étudiant
Inscription : avril 2011
Messages : 63
Détails du profil
Informations personnelles :
Nom : Homme khmaies guesmi
Localisation : Tunisie

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

Informations forums :
Inscription : avril 2011
Messages : 63
Points : -3
Points : -3
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 :
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 :
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
pfakhmaies est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 06/07/2011, 23h29   #2
Membre confirmé
 
Homme
Développeur informatique
Inscription : avril 2011
Messages : 196
Détails du profil
Informations personnelles :
Sexe : Homme
Localisation : Italie

Informations professionnelles :
Activité : Développeur informatique
Secteur : Transports

Informations forums :
Inscription : avril 2011
Messages : 196
Points : 298
Points : 298
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 :
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 :
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 :
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
}
?>
fab256 est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 07/07/2011, 01h09   #3
Invité de passage
 
Homme fedi ben mohamed
Étudiant
Inscription : juillet 2011
Messages : 23
Détails du profil
Informations personnelles :
Nom : Homme fedi ben mohamed
Localisation : Tunisie

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

Informations forums :
Inscription : juillet 2011
Messages : 23
Points : 1
Points : 1
bonjours ,

merci beaucoup ,, j'ai fait,,mais j'ai obtient des donné different ,et il apparait un erreur
Citation:
Undefined index: $sn ..
notez bien que j'ai mis au debut de code:
dans l'attente....
fediminyar est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 07/07/2011, 23h46   #4
Membre confirmé
 
Homme
Développeur informatique
Inscription : avril 2011
Messages : 196
Détails du profil
Informations personnelles :
Sexe : Homme
Localisation : Italie

Informations professionnelles :
Activité : Développeur informatique
Secteur : Transports

Informations forums :
Inscription : avril 2011
Messages : 196
Points : 298
Points : 298
Le probleme viens surement de ton formulaire FORM
il doit ressembler a ceci :
Code :
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>
fab256 est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 08/07/2011, 09h22   #5
 
Homme khmaies guesmi
Étudiant
Inscription : avril 2011
Messages : 63
Détails du profil
Informations personnelles :
Nom : Homme khmaies guesmi
Localisation : Tunisie

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

Informations forums :
Inscription : avril 2011
Messages : 63
Points : -3
Points : -3
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 :
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>
pfakhmaies est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 08/07/2011, 15h34   #6
Membre confirmé
 
Homme
Développeur informatique
Inscription : avril 2011
Messages : 196
Détails du profil
Informations personnelles :
Sexe : Homme
Localisation : Italie

Informations professionnelles :
Activité : Développeur informatique
Secteur : Transports

Informations forums :
Inscription : avril 2011
Messages : 196
Points : 298
Points : 298
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"!
fab256 est déconnecté   Envoyer un message privé Réponse avec citation 00
Réponse Proposer ce sujet en actualité
Outils de la discussion



Fuseau horaire GMT +2. Il est actuellement 21h39.


 
 
 
 
Partenaires

Hébergement Web