Déplacer un enregistrement table1 vers table2
Voila déjà 5 jours que je cherche une solution a mon problème toujours pas de solution (:-(
je souhaiterais envoyer, après sélection de checkbox de mon choix , les enregistrements dans une autre table avec les memes champs et faire un ->
Code:
INSERT INTO table_2 SELECT * FROM table_1 WHERE id IN('.implode(',',$_POST['msg']).')');
En gros j'ai dans ma page des checkbox qui récupèrent dans value les id des enregistrement ->
Code:
<input name="msg[]" class="checkbox" type="checkbox" id="msg[]" value="'.$result['id'].'">
en cliquant sur envoyer j'attérie dans la page RESULTAT.PHP
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13
| print_r ($_POST['msg']); // il m'affiche bien avec les id -> Array ( [0] => 162 [1] => 163 [2] => 164 )
if(isset($_POST['msg']))
{
foreach($_POST['msg'] as $msg)
{
$sql='INSERT INTO table_2 SELECT * FROM tb_gestion WHERE id IN('.implode(',',$_POST['msg']).')';
}
} |
MAIS IL SE SE PASSE RIEN , auriez vous une idée s'il vous plait ne suis vraiment bloquée la
//PAGE INDEX.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
|
<form id="RESULTAT" name="RESULTAT" method="post" action="RESULTAT.php">
<?
$sql = 'SELECT * FROM table1 WHERE utilisateur="'.$_SESSION['login'].'" ' ;
$req = mysql_query($sql) or die('Erreur SQL !<br>'.$sql.'<br>'.mysql_error());
echo'<table width="95%" border="0" align="center" class="Ltableau" id="example" cellspacing="1" cellpadding="1">
<thead><br>
<tr>
<th width="5%" class="Htab">Date></th>
<th width="7%" class="Htab">Priorité</th>
<th width="5%" align="center" bgcolor="#E70010">transferer</th>
<th>S</th>
</tr></thead>';
echo"<tbody>";
while($result = mysql_fetch_assoc($req)) {
echo "<tr>";
echo "<td bgcolor='#CCCCCC' width='5%'>".$result['date'];
echo"</td>";
echo "<td class='".$color."' width='7%' align='center'>".$result['priorite'];
echo '<td width="1%"><input name="msg[]" class="checkbox" type="checkbox" id="msg[]" value="'.$result['id'].'"></td>';
}
echo "</td></tbody></table>";
echo"
<input class='Submit' type='submit' name='Submit' value='transferer'>";
?> |
//PAGE RESULTAT.PHP
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14
| print_r ($_POST['msg']); // il m'affiche bien avec les id -> Array ( [0] => 162 [1] => 163 [2] => 164 )
if(isset($_POST['msg']))
{
foreach($_POST['msg'] as $msg)
{
$sql='INSERT INTO table_2 SELECT * FROM tb_gestion WHERE id IN('.implode(',',$_POST['msg']).')';
}
} |
en fait il ne se passe rien et je ne comprend pas pourquoi,
Merci d'avance de votre aide je suis un peu désespérée la (:-)
:cry: