开发者

Get and display the multiple choice that have been selected

So this is my form that let the users select input from a table :

echo"Please select questions to analyze : ";
$qsq = mysql_query("SELECT DISTINCT question_text FROM questions ");
echo "<form name='whatever' action='next.php' method='get'>";

while($row = mysql_fetch_assoc($qsq))
{

echo"<input type='checkbox' name='choice' value='" . $row['question_id'] . "' /> ". $row['question_text'] . '<br />';

}

echo"<br>";开发者_运维问答
echo "<input type='submit' value='submit' /></form>";

In the next.php where the form directs to,how can i display the selected one ? should i make an array or any better suggestions ?Please help me i am a beginner in this.Thanks in advance.


echo"<input type='checkbox' name='choice[]' value='" . $row['question_id'] . "' /> ". $row['question_text'] . '<br />';

Add [] to the name of checkbox.

This will post the check box as an array.

$_POST['choice'] = array('questionId1', 'questionId2');
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜