Jump to content

[SOLVED] Stuck with while


isharis

Recommended Posts

<?php

// Last Modified 17th August

include('templates/header.php'); // Header template
include('config/config.php'); // Includes configuration files
include('lib/functions.php'); // Load all functions from Library

$select_questions = mysql_query("SELECT * FROM questions") or die(mysql_error());
echo "<form method=\"post\">";
while($row = mysql_fetch_array($select_questions)){
    $questions = $row['question'];
    $qID = $row['id'];
    echo $questions."<br/>For: <input type=\"radio\" value=\"For\" name=\"".$qID."\"><br/>Against: <input type=\"radio\" value=\"Against\" name=\"".$qID."\"><br/><br/>";
    $posted_answer = $_POST[$qID];
    $submit_useranswer = $_POST['submit_useranswers'];
}

echo "<input type=\"submit\" name=\"submit_useranswers\">";
echo "</form>";

if(isset($submit_useranswer)){
    $user_answer = array($posted_answer);
    print_r($user_answer);
}

include('templates/footer.php'); // Footer Template

?> 

 

I have assigned the question_id to the radio boxes names so I can post them in an array and also differentiate. I'm stuck at  $posted_answer = $_POST[$qID];, I want the radio values for each qID to be stored in that variable($posted_answer) and somehow I can convert those values into an array.

 

Any ideas? If I'm not clear, please let me know.

 

If there's a better way, do let me know.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.