using variables in $_post[]
<p>I have been using variable in the name part of the input tag. Now while access answers as selected by users using $_post,It gives error as undefined index.Tell me how to get answers of all questions  as selected .   </p>

<pre><code>echo "&lt;form method=\"post\" action=\"\"&gt;";
    $query=mysql_query("select q_detail,q_id from question where category=\"$value2\"",$connection);
    if(!$query)
    {
        echo mysql_error().'query failed';
    }
    $ans=1;
    while($value1=mysql_fetch_array($query))
    {
        echo "Q-$i"."&amp;nbsp;&amp;nbsp;";
        echo $value1['q_detail']."&lt;br /&gt;";
        $i++;
        $qno=$value1['q_id'];
        $query1=mysql_query("select * from answer where ans_id=$qno");
        if(!$query1)
        {
            echo mysql_error().'query failed';
        }

        while($value2=mysql_fetch_array($query1))
        {
            $opt=$value2['option1'];
            $opt1=$value2['option2'];
            $opt2=$value2['option3'];
            $opt3=$value2['correct'];
            echo "&lt;input type=\"radio\" value=\"$opt\" name=\"$ans\"&gt;";
            echo "&lt;span class=\"margin\"&gt;$opt&lt;/span&gt;";
            echo "&lt;input type=\"radio\" value=\"$opt1\" name=\"$ans\"&gt;";
            echo $opt1."&amp;nbsp;&amp;nbsp;";
            echo "&lt;input type=\"radio\" value=\"$opt2\" name=\"$ans\"&gt;";
            echo $opt2."&amp;nbsp;&amp;nbsp;";
            echo "&lt;input type=\"radio\" value=\"$opt3\" name=\"$ans\"&gt;";
            echo $opt3."&amp;nbsp;&amp;nbsp;&lt;br /&gt;&lt;br /&gt;";
            $ans++;             
        }

    }
    echo"&lt;input type=\"submit\" name=\"submit\" value=\"submit\"&gt;";
    echo "&lt;/form&gt;";
</code></pre>
