html - php-handling dynamic created radio button -



html - php-handling dynamic created radio button -

i creating dynamic quiz page 2 options each question , radio button compare value value in database in order know if reply correct

the questions , choices stored in database , retrieved in code every question in own table

<html> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8"> <title></title> </head> <body> <form method="post" class="regularfont" action="quiz.php"> <?php require_once 'database.php'; $res = mysql_query("select * quiz"); while ($row1 = mysql_fetch_array($res)) {\\create table every entry echo <<<_end <div style="padding-bottom: 30px"> <table border=""> <th colspan="2">question 1</th> <tr> <td colspan="2"> $row1[0] </td> </tr> <tr> <td>$row1[1]<input type="radio" name='true1[$row1[1]]' value='1'></td> <td>$row1[2]<input type="radio" name='true1[$row1[1]]' value='2'></td> </tr> </table> </div> _end; } ?> <input type="submit" value="submit"> </form> </body>

so value of each radio button can 1 or 2 , , want compare value database have right reply number 1 or 2

i tried use

foreach ($_post['true1'] $value)

but cant right , want work dynamically number of inputs

you should use:

foreach ($_post['true1'] $key => $value)

you need $key know row of database radio selection refers to.

php html

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

django - Access session in user model .save() -

php - .htaccess Multiple Rewrite Rules / Prioritizing -