Bonjour

j'ai une table produit j'affiche tout mes produit ca marche bien.

apres affiché mes produits

j'ai une autre table ou je doit inserer id: de la table afficher produit et le login récuperé de la session le login je recupère bien.
je doit inserer id + login dans la table produitutilisateur

mais j'ai le problème avec id de la table produit j'ai met un compteur 'id".$cpt."'
donc c'est la requete 'insert into produitutilisateur values("'. $_GET['id".$i."']. '" , "'.$login.'" )'; qui marche pas bien regardez bien le code en dessous ca fait deux jours que je suis coincé
a+

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
 
<?php
 
 
echo"<form method = 'post' action = 'produitutilisateur.php?valider=ok'>";
session_start ();
$login = $_SESSION['login'];
 
$connexion = mysql_connect("localhost", "root", "");
mysql_select_db('stage', $connexion);
$sql = 'select * from produit ';
$resultat = mysql_query($sql);
$nbl = mysql_num_rows($resultat);
 
echo "<table cellpadding = '5' border = '1'>";
echo"<tr>";
 
 
echo"<td>Produit</td>";
echo"<td> Choix </td>";
echo "</tr>";
$cpt=1;
while($data = mysql_fetch_array($resultat))
{
 
printf("<tr><td><input type= 'text' name = 'id".$cpt."' value='".$data['idP']."' >%s</td><td>%s</td></tr>", $data['intitule'], "<input type= 'checkbox' name = 'choix".$cpt."' checked='false' ></>");
$cpt++;
} 
 
echo "</table><br/>";
 
 
if(isset($_GET['valider'])){
$login = $_SESSION['login'];
 
echo $login;
echo $_GET['id".$i."'];
 
for($i = 1; $i<= $nbl; $i++) {
 
 
$requete = 'insert into produitutilisateur values("'. $_GET['id".$i."']. '" , "'.$login.'" )'; $res = mysql_query($requete); 
 
 
}
 
 
 
}
 
 
 
 
echo"<input type = 'submit' name = 'valider' value = 'selectionner vos produits'/>";
 
 
echo"</form>";
 
 
?>