So..in a textarea I’m bringing the values stored in my table to modify them like this:
$l=mysql_query("select * from intrebari where cod_chestionar='".$_SESSION['cod']."'");
echo "<form method='POST' action='lalalalal.php'>";
echo "<textarea name='edit' cols='50'>";
while($p=mysql_fetch_array($l))
{
echo $p[denumire_intrebare];
echo "\n";
}
echo "</textarea>";
echo "<input type='submit' value='Finished' name='save_edit'/>";
echo "</form>";
}
It’s all fine..the values, that are questions, are brought on separate line. Now I want to make an update if necessary. So in my update file I’m doing like this:
$a=$_POST['edit'];
$a_array=explode("\n",$a);
foreach($a_array as $b)
{
$sql=mysql_query("UPDATE intrebari set denumire_intrebare='$b' WHERE cod_chestionar='".$_SESSION['cod']."'");
echo $b;
}
I want for all questions that have the same cod_chestionar to make the update. In this moment if I make an update the same value is put to all my questions. If I echo it the values are brought to me as I modified them but it doesn’t make the update in table. Can you give an opinion because I just can’t figure it out.
You are using one
<textarea>for multi records, you have to use separatetextareas to be able to modify them and update them separately.You must have an unique ID field in your
intrebaritable and we will name itid, we will use it do solve your problem:And the update: