Jump to content

assigning data from a query to radio buttons


burge124

Recommended Posts

hi i have a mysql query that randomly prints a question & three possible answers, although i dont know how to assign each answer to a radio button... heres my code so far

 

$result = mysql_query("SELECT * FROM question ORDER BY RAND() LIMIT 1");


while($row = mysql_fetch_array($result))
  {
   echo $row['QuestionTitle'];
   echo "<br />";
   echo $row['AnswerA'];
   echo "<br />";
   echo $row['AnswerB'];
   echo "<br />";
   echo $row['AnswerC'];
   echo "<br />";
  }

 

then the radio buttons consist of...

 

<INPUT TYPE="RADIO" NAME="question2"VALUE="answer2.1">answera<BR>
<INPUT TYPE="RADIO" NAME="question2"VALUE="answer2.2">answerb<BR>
<INPUT TYPE="RADIO" NAME="question2" VALUE="answer2.3">answerc<br>

 

thanks

Are you trying to say that you don't know how to make the answera answerb etc from the db list next to the input button?  If you are, you'd just save the data from the loop into a var, then below echo out that var.  If this isn't what you're asking, could you be more specific?

 

Thanks.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.