如何使用单选按钮?

How can I use the radio button correctly?

I have questions on our evaluation for the instructor and we store it on database called tbl_question. Then we call the question and together with it, we assign a radio button on the side as rate like 5 as always, 4 as often and etc.. we must have one answer for each question. The problem is we can only select one value in all the question. If the radio 5 is the answer for question one then if he also answer 5 in question two then in question one answer will not be selected instead it transfer to question 2. If I answer 5 in question one. I can also answer 4 in question one.

<?php
 include('connection.php');
 $qry="SELECT * FROM tbl_question";
  $res=mysql_query($qry) or die(mysql_error());
  $nr= mysql_num_rows($res);

      ?> `


   <table align="center" border="1"  cellspace="10" style="width:700px text-align:center border-collapse:collapse border:1px solid black">
  <tr>
 <th>QUESTIONS</th>
 <th>Always<br><img src="5.png" width="50" height="40"/></th>
 <th>Often<br><img src="4.png" width="50" height="40"/></th>
 <th>Sometimes<br><img src="3.png" width="50" height="40"/></th>
 <th>Seldom<br><img src="2.png" width="50" height="40"/></th>
 <th>Never<br><img src="1.png" width="50" height="40"/></th>
</tr>

     <?php while ($rows=mysql_fetch_array($res)){ ?>


 <tr>
  <td> <?php echo '<strong>'. $rows['eval_question']. '</strong>'; ?> </td>
 <td> <input type="radio" name="5" value="5"> </td>
<td> <input type="radio" name="4" value="4"> </td>
<td> <input type="radio" name="3" value="3"> </td> 
<td> <input type="radio" name="2" value="2"> </td>
 <td> <input type="radio" name="1" value="1"> </td>
 </tr>    

Read up a little bit on how to create <div id="[div_id]"> s.

You will be able to show or hide any parts of any lists by wrapping them in <div> tags, and using a JavaScript function to make them visible or not. The code looks like this:

document.getElementById("[div_id]".style.display  = "block" //visisble
document.getElementById("[div_id]".style.display = "none" //not visible

The contents of the entire form will be passed once the form is submitted regardless of the state of the <div>.

Here is a better code example.

Give each member of a radio group the same name, then the checked radio button will send its value with that name.

name="5" # or 4, 3, 2, 1

should be something like

name="star_rating_question_1" value="5"