Ver Mensaje Individual
  #3 (permalink)  
Antiguo 10/06/2015, 07:43
Avatar de enlinea777
enlinea777
 
Fecha de Ingreso: mayo-2008
Ubicación: frente al pc
Mensajes: 1.830
Antigüedad: 16 años
Puntos: 127
Respuesta: Relacionar checkbox con id

hay que variar un poco tu codigo:
Código PHP:
while($row $votantes->fetch_assoc()) {
        echo 
"<tr>
                        <td>
                         <input type='hidden' name='id_votante[]' value='"
.$row["id_voto"]."'> ".$row["votante_nif"]."
                        </td>
                        <td>
                           "
.$row["votante_n"]."
                        </td>
                        <td >
                            "
.$row["votante_a"]."
                        </td>
                        <td>
                           <input type='checkbox' name='acep_"
.$row["id_voto"]."' value='acep'>Aceptada<input type='checkbox' name='dene_".$row["id_voto"]."' value='dene'>Denegada 
                        </td>
                        
             </tr>"
;
    }
    echo </
table
despues hay que recivir los datos asi:
Código PHP:
<?
$id_votante
=$_POST['id_votante'];
$total=count($id_votante);

for (
$i=0$i $total $i++) { 
    
$idvotante=$id_votante[$i]; // llama al id del votante
    
$checkbox_acepta=$_POST['acep_'.$idvotante];
    
$checkbox_denega=$_POST['dene_'.$idvotante];

    if(
$checkbox_acepta=='acep'){
        
$msg='el votante acepta';
    }
    if(
$checkbox_denega=='dene'){
        
$msg='el votante denega';
    }
    echo 
'id del votante: '.$idvotante.'     -      checkbox elegido: '.$msg.'<br><br>';
}