how can i insert the value of radio button which have same name in php?

   echo "<form  action='#' method='post'>";
      echo "<table border='1' style='width:500px;'> <br />";
      $i=1;
       while($row = mysql_fetch_array($result))
        {




            echo "<tr>";
            ?>
       <input type="text" value="<?php echo $row['answer'];?>" name="id" 
       style="display:none;">
    <strong><?php echo $i;?>.<?php echo $row['question'];?></strong><br />
       <br /><br />


   A.&nbsp;&nbsp;<input type='radio' value='A' name='answer' id="answer<?php
   echo $i;?>"/> 
 <?php echo  $row['a'];?> <br />


 B.&nbsp;&nbsp;<input type='radio' value='B' name='answer' id="answer<?php
 echo $i;?>" />
  <?php echo $row['b'];?><br />
 C.&nbsp;&nbsp;<input type='radio' value='C' name='answer' id="answer<?php
   echo $i;?>" />
  <?php echo $row['c'];?><br />
 D.&nbsp;&nbsp;<input type='radio' value='D' name='answer' id="answer<?php 
 echo $i;?>" />
 <?php echo  $row['d'];?> <br /><br /><br />
  <?php
echo "</tr>";


$i++;
}
}
?>
 <input type='submit' name='next' value='Submit' style="background-color: 
  #2f4e71;color: white;width: 107px;height: 35px;border:1px solid  #2f4e71 
  ">
 <?php
   echo "</table>";
    echo "</form>";




    ?>

this is the code where i am trying to insert the value of radio buttons which are in the loop
but the problem is the name are same for all the buttons and insert only one value
is it have any solution?


Source: php

Leave a Reply