I have a question about updating database with multiply lines from textarea. Each line is from a different row in database so I need a way in which I can update each line.
Each line has a unique id. I have a hidden input that passes each id.
It looks like this.
$assign_id = explode( " ", $assign_id);
for($a=0;$a<count($assign_id);$a++){
echo"
<input type=\"hidden\" name=\"assign_id\" value=\"".$assign_id[$a].\">";
}
here's the code i'm using for the update query.
for ($i=0;$i<count($_POST['assign_id']); $i++) {
$assign_id = $_POST['assign_id'][$i];
echo $assign_id;
}
foreach($assign_id as $assign_id){
echo $assign_id;
$option_id = explode("\n", $_POST['option_id']);
for ($i=0;$i<count($option_id); $i++) {
$option_id = explode(" ", $option_id[$i]);
$query = "update ".$prefix."options_set set option_name='$option_id[$i]' where assign_id='$assign_id'";
$result = mysql_query($query) or die("Error: " . mysql_error());}
}
}