Select only one item

2

Here is the code:

<?php while($ver=mysql_fetch_row($busca)){ ?>
    <tr>
        <td><input type="radio" value="<?php echo "$var[0]"; ?>"></td><td><?php echo "$ver[0]"; ?></td>
        <td><?php echo "$ver[1]"; ?></td>
        <td><?php echo "$ver[2]"; ?></td>
        <td><?php echo "$ver[3]"; ?></td>
        <td><?php echo "$ver[4]"; ?></td>
    </tr>                  
<?php } ?>

And here only one should be selected, but it is not what is happening:

    
asked by anonymous 16.11.2015 / 19:58

2 answers

3

There is no element of "name" inside the input radio so that only one can be selected.

<tr>
  <td>
    <input type="radio" value="1" name="group1" />
  </td>
  <td>1</td>
  <td>Col 2</td>
  <td>Col 3</td>
  <td>Col 4</td>
  <td>Col 5</td>
</tr>

<tr>
  <td>
    <input type="radio" value="2" name="group1" />
  </td>
  <td>2</td>
  <td>Col 2.2</td>
  <td>Col 3.2</td>
  <td>Col 4.2</td>
  <td>Col 5.2</td>
</tr>

<tr>
  <td>
    <input type="radio" value="3" name="group1" />
  </td>
  <td>3</td>
  <td>Col 2.3</td>
  <td>Col 3.3</td>
  <td>Col 4.3</td>
  <td>Col 5.3</td>
</tr>
    
16.11.2015 / 20:04
0

Try using as your first ID field, ie using $ver[1] and use the name attribute.

<input type="radio" value="<?php echo "$ver[0]"; ?>" name="selecionado" />
    
16.11.2015 / 20:03