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>";
?> |
Partager