dqifn68206 2013-10-17 11:29
浏览 172

如何在另一个php页面中获取多个单选按钮值?

I have multiple questions and each question has 4 answers, I display all questions and their answers in PHP, by:

 while($row=mysqli_fetch_array($rs)) 
  {
   echo "question:".$row['question']."<br>";
  ?>
   <input type="hidden" name="id[<?php echo $row[id] ?>]" value="<?php echo $row[id]    ?>" />
  <?php echo $row['op1'] ?>
  <input type="radio" name="opt[<?php echo $row['id'] ?>]" value="<?php echo $row['op1'] ?>-<?php echo $row['id'] ?>" /><br>
   <?php echo $row['op2'] ?>
  <input type="radio" name="opt[<?php echo $row['id'] ?>]" value="<?php echo $row['op2'] ?><?php echo $row['id'] ?>" /><br>
  <?php echo $row['op3'] ?>
  <input type="radio" name="opt[<?php echo $row['id'] ?>]" value="<?php echo $row['op3'] ?><?php echo $row['id'] ?>" /><br>
  <?php echo $row['op4'] ?>
   <input type="radio" name="opt[<?php echo $row['id'] ?>]" value="<?php echo $row['op4'] ?><?php echo $row['id'] ?>" /><br>

 <?php
  }

 ?>
  <input type="submit"  value="answer" /><br>

How can I get radio button value for each $row['id'] on the next page.

  • 写回答

1条回答 默认 最新

  • duanfu2562 2013-10-17 11:41
    关注

    use form action as your redirection page and method POST or GET as you prefer, then try

    print_r($_POST);// as your method and you could use $_REQUEST
    

    for GET method

    print_r($_GET);
    

    you will see radio button value in array,...

    if we use $_GET method as form attribue then we will retrieve form value by $_GET if we use $_POST method as form attribue then we will retrieve form value by $_POST

    and $_REQUEST can retrieve value posted by both method, but Request is not a method

    评论

报告相同问题?

悬赏问题

  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料