0

質問を更新するためのコードは機能していますが、回答を更新すると機能しません。どうすればこれを修正できますか? ヘルプ。ありがとう。:)

これは私のフォームにあります:

<?php do { ?><tr><th width="170" scope="col"><input type="checkbox" name="selected[]"  value="<?php echo $row_Recordset1['question_id']; ?>" />
  Description:</th>
  <td colspan="2" scope="col">old:
  <?php echo $row_Recordset1['question_description']; ?>
  new:<input name="questiondesc[]" type="text"  size="50" />/td>
  <td width="549" colspan="2" scope="col"><div align="left"></td>
  </tr>
<input type="hidden" name="ansid[]" value="<?php echo $row_Recordset2['answer_id']; ?>" />
<input name="answerdesc[]" type="text" size="20" value="<?php echo $row_Recordset2['answer_description']; ?>" /><?php

 if($row_Recordset2['answer_iscorrect'] == 1){
 echo "Correct";
}
 ?>
<?php } while ($row_Recordset2 = mysql_fetch_assoc($Recordset2)); ?>
<?php } while ($row_Recordset2 = mysql_fetch_assoc($Recordset2)); ?>

/////これは私の更新コードです

if(isset($_POST['selected'])){

$selected = $_POST['selected'];
$question = $_POST['questiondesc'];
$answer = $_POST['answerdesc'];
$answerid = $_POST['ansid'];

for ($i = 0; $i < sizeof($selected); $i++)
{
    $sql = sprintf("UPDATE exam_questions SET question_description = '%s' WHERE question_id = '%s'", 
           mysql_real_escape_string($question[$i]), 
           mysql_real_escape_string($selected[$i]));
    mysql_query($sql)or die(mysql_error());

    for($x = 0; $x < sizeof($answerid); $x++){
    $gomugomu = sprintf("UPDATE exam_answers SET answer_description = '%s' WHERE answer_question_set_id = '%s'",
           mysql_real_escape_string($answer[$x]), 
           mysql_real_escape_string($answerid[$x]));
    mysql_query($gomugomu)or die(mysql_error());
    }
}

}
?>
4

1 に答える 1

0

あなたの ansid と answerdesc は配列ではありません

<input type="hidden" name="ansid" .....
<input name="answerdesc" ....

<input type="hidden" name="ansid[]" ...
<input name="answerdesc[]" ...
于 2013-08-28T06:59:24.337 に答える