Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/238.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
php中的值获取数组_Php - Fatal编程技术网

php中的值获取数组

php中的值获取数组,php,Php,我正在做一个在线测试,我从数据库中获取问题和选项。。。。 我需要选择他们选择的选项和问题id…是否转到下一页回答问题…我只得到他们选择的选项我需要获得所有值 我的php代码如下 <tr> <td height="30"><?= $id?></td> <td height="30" colspan="2"><?= $question ?></td> </tr> <?p

我正在做一个在线测试,我从数据库中获取问题和选项。。。。 我需要选择他们选择的选项和问题id…是否转到下一页回答问题…我只得到他们选择的选项我需要获得所有值

我的php代码如下

 <tr>
    <td height="30"><?= $id?></td>
    <td height="30" colspan="2"><?= $question ?></td>
  </tr>

   <?php 
      if($option1!='') { ?>

  <tr>
    <td height="30"><input type="radio" name="answer[<? echo $id?>]"  value="<?php echo $id?>-<?php echo $option1?>" /></td>
    <td height="30" colspan="2"><?= $option1?></td>
  </tr>
  <?php }?>
  <?php if($option2!='') {?>
  <tr>
    <td height="30"><input type="radio" name="answer[<? echo $id?>]"    value="<?php echo $id?>-<?php echo $option2?>" /></td>
    <td height="30" colspan="2"><?= $option2?></td>
  </tr><?php }?>
  <?php if($option3!='') {?>
  <tr>
    <td height="30"><input type="radio" name="answer[<? echo $id?>]"    value="<?php echo $id?>-<?php echo $option3?>"  /></td>
    <td height="30" colspan="2"><?= $option3?></td>
  </tr><?php }?>
   <?php if($option4!='') {?>
  <tr>
    <td height="30"><input type="radio" name="answer[<? echo $id?>]"    value="<?php echo $id?>-<?php echo $option4?>"  /></td>
    <td height="30" colspan="2" ><?= $option4?></td>
  </tr>

 <?  }


您可以将所有答案作为隐藏元素发送:

<input type="hidden" name="allanswers[]" value="Answer 1" />
<input type="hidden" name="allanswers[]" value="Answer 2" />
<input type="hidden" name="allanswers[]" value="Answer 3" />
<input type="hidden" name="allanswers[]" value="Answer 4" />

$id将对所有选项具有相同的值

因此,您可能需要将
name=“answer”
改为:

<input type="radio" name="answer" value="<?php echo $id?>-<?php echo $option2?>" />

所以当你看$\u帖子或$\u GET what you gets you gets对不起,我就是不明白这个问题。