0

basically i have a database, which contains a random amount of questions i have then printed this out as a php table using a query. there is as many textboxes to input marks as there are questions in the database. I want to create an array of my inputted data and then update the database with the marks in.

Here is my code

                    echo "<table border = '0' cellpadding ='10px'>";
            echo "<tr>
                <td> Question <td>Mark</td><td>Criteria</td>
                <td>Feedback</td>
                </tr>";

            while ($row = mysql_fetch_array($result))
            {   
                $question[]=$rows['question']; 
                echo "<tr>";
                echo "<td>". $row['question']. "</td>";
                echo "<td>" ."<input type = 'text' name = 'mark[]' size = '1' value = '0' id = 'mark'/>/". $row['maxMark'] . "</td>";
                $maxMark[] = $row['maxMark'];
                echo "<td>".$row['criteria']."</td>";
                echo "<td>" . "<textarea name = 'feedback[]' id= 'feedback'>Enter Feedback here</textarea>". "</td>";
                echo "</tr>";

            }

echo "</table>";
echo "</tr>\n";
echo "</table>";

I am not sure how to create the array, with the marks you input. please help. In short i want to populate an array with the marks i input

1
  • did you test your code? Isn't it working? Commented Mar 26, 2012 at 22:15

1 Answer 1

1

This is rather easy to be done. All you have to do is setting the attribute name of your input controls and add an index.

Example:

<input type="text" name="name[0]" /><input type="text" name="mark[0]" />
<input type="text" name="name[1]" /><input type="text" name="mark[1]" />

The post (or get) data your script receives will then contain an array instead of a single variable.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.