PHP variable in a value HTML

0

How do I put the php variable in the following value:

<?php
    while($ver=mysql_fetch_row($busca)){ 
        $id1 = $ver[0];
?>
        <tr>
            <td><input type="radio" value="$id1"></td>
            <td><?php echo "$ver[0]"; ?></td>
    # code ...

The way I did value="$id1" did not work. Only one of the "radios" should be selected, so the values must be different:

    
asked by anonymous 16.11.2015 / 19:22

2 answers

4

Use the php tag <?php echo $id1; ?> or <?=$id1?> (if php short tags is enabled)

ex:

<input type="radio" value="<?php echo $id1; ?>">
    
16.11.2015 / 19:26
0

In the first <td> you did not put tags of PHP .
Not following <td> you did but you are using a vector and the string interpreter tries to capture only var in such a way that I understand the [0] index as a string and not index.

Solving

<input type="radio" value="<?php echo $id1; ?>"> // var direto
ou
<input type="radio" value="<?php echo $var[0]; ?>"> // var direto
ou
<input type="radio" value="<?php echo "{$var[0]}"; ?>"> // {} para indicar inicio e fim de var, inclui o index [0]
    
16.11.2015 / 19:36