Este es mi programa donde intento almacenar en la columna 'choice_anser' las respuestas de opción múltiple:
Código
<?php // Start the session $servername = "localhost"; $username = "root"; $password = ""; $dbname = "project"; $conn = new mysqli($servername, $username, $password, $dbname); /*echo*/ $id=$_GET['id']; $sql = "SELECT * FROM exercises where exercise_id='$id'"; $result = $conn->query($sql); /*Check connection*/ ?> <div id="centered_B" class="header"> <?php $row = $result->fetch_assoc(); echo '<h1>' . $row["exercise_id"]. ". " . $row["title"] . '</h1>' . "<br>" . '<p>' . $row["text"] . '</p> <img width="603" height="auto" src="' . $row["image_path"] . '"><br><br> <form method="post" > <input type="radio" name="choice" value= "1" /><img src="' . $row["image_path_A"] . '"/><br> <input type="radio" name="choice" value= "2" /><img src="' . $row["image_path_B"] . '"><br> <input type="radio" name="choice" value= "3" /><img src="' . $row["image_path_C"] . '"><br>'; echo '</form>'; /*var_dump($id)*/ ?> <br><br><br><!--- Select difficulty ---> <p2>Select difficulty level:</p2> <form action='' method='post'> <select name="choose" id="choose">> <option value="1" <?php if($row["difficulty"]=="1") { echo "selected"; } ?> >1</option> <option value="2" <?php if($row["difficulty"]=="2") { echo "selected"; } ?> >2</option> <option value="3" <?php if($row["difficulty"]=="3") { echo "selected"; } ?> >3</option> <option value="4" <?php if($row["difficulty"]=="4") { echo "selected"; } ?> >4</option> <option value="5" <?php if($row["difficulty"]=="5") { echo "selected"; } ?> >5</option> </select> <br><br><br><!--- Button ---> <!-- <button class="buttonSubmit" >Submit</button>--> <input type="submit" name="submit" value="Submit"> <button class="buttonNext" >Next Question</button> </form> </div><!--- end of centered_B div ---> <?php $user_id = $_SESSION['user_id']; $user_check_query = "SELECT * FROM users WHERE id='$user_id'"; $choice_answer=$_POST['choice']; $difficulty=$_POST['choose']; // */$user_id = $_SESSION['user_id'];*/ $query = "INSERT INTO answers (exercise_id_fk, student_id, difficulty_student, choice_answer) VALUES ('$id','$user_id', '$difficulty', '$choice_answer')"; } } } ?>