user320522
user320522

Reputation: 25

Calling Posted Array in PHP And SQL

I'm naming my input fields as their row value in the input radio button in my database. What I'm having trouble with is calling that name inside of the $_Post[ ] brackets. How would I accomplish this?

Select Statement

$getQuestions = "
    SELECT
        *

    FROM
        questions
    WHERE questions.active = '1'

    ORDER BY
        questionID
";

PHP Code

if ($aRow['correct'] == 1) {
 $tableString .="<input name=". $qRow['questionID'] ." type='radio'>" .


$question = mysql_real_escape_string($_POST[$qRow['questionID']][$i]);

Upvotes: 1

Views: 32

Answers (1)

Taursus
Taursus

Reputation: 71

I cannot comment yet, so I got to write it here.

When your code doesn't work, always debug it first, check what's inside variables that may give you a clue on what to do and in this case I think you could dump $_POST and $qRow and see what they contain, so put this code:

var_dump($_POST);
var_dump($qRow);

before:

$question = mysql_real_escape_string($_POST[$qRow['questionID']][$i]);

If it didn't help you to figure it out, then just post the result of those dumps

Upvotes: 0

Related Questions