简体   繁体   English

PHP Query to HTML单选按钮

[英]PHP Query to HTML radio buttons

i am a beginner in PHP.I have this query in my code. 我是PHP的初学者。我的代码中有此查询。

$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 ? 我想在单选按钮中显示$qsq的结果以便可以选择它。然后将选择发送到另一个带有另一个查询的表中。有人可以帮我编码吗? 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. 您没有告诉您任何有关表格的信息,所以我不能给您任何准确的信息(不是那个ID一定要,我只是想给您广泛的笔触),但是听起来您想要一个带有一组单选按钮的表单:每排一个。

$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. 提交此表单将发送到URL next.php/choice=# ,您可以在其中从$_GET检索选择并执行所需的操作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM