开发者

PHP Query to HTML radio buttons

开发者 https://www.devze.com 2023-02-22 09:50 出处:网络
i am a beginner in PHP.I have this query in 开发者_如何学运维my code. $qsq = mysql_query(\"SELECT DISTINCT question_text FROM questions \");

i am a beginner in PHP.I have this query in 开发者_如何学运维my code.

$qsq = mysql_query("SELECT DISTINCT question_text FROM questions ");

I want to display the results of $qsq in radio buttons so that it can be selected.Then send the choices to another table with another query.Can someone help me with the coding please ? Thanks in advance.


You don't tell anything about your table, so i cant give you anything exact (not that id necessarily want to, im just trying to give you broad strokes), but it sounds like you want a form with a group of radio buttons: one for each row.

$res = mysql_query("SELECT id, question_text FROM questions");
echo "<form name='whatever' action='next.php' method='get'>";
while($row = mysql_fetch_assoc($res))
{
   echo "<input type='radio' name='choice' value='" . $row['id'] . "' /> ". $row['question_text'] . '<br />';
}
echo "<input type='submit' value='submit' /></form>";

Submitting this form will send to the url next.php/choice=# where you can retrieve the choice out of $_GET and do whatever you need to.

0

精彩评论

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

关注公众号