Ver Mensaje Individual
  #18 (permalink)  
Antiguo 15/12/2012, 22:02
johnse0828
 
Fecha de Ingreso: diciembre-2012
Mensajes: 24
Antigüedad: 11 años, 4 meses
Puntos: 2
Respuesta: llenar arreglo con checkbox y caja de texto

Hola, no sé si te entienda bien... Pero en el "name" de las cajas de texto un arreglo indexado, es decir
Código HTML:
<input name="norm[0]" type="checkbox" value="1">Programas Sociales en los que participa la persona 
<input name="anio[0]" value="" type="text" />
<input name="norm[1]" type="checkbox" value="2">Participante en el Programa Avancemos 
<input name="anio[1]" value="" type="text" />
<input name="norm[2]" type="checkbox" value="3">Participante en el Programa EMPLEATE 
<input name="anio[2]" value="" type="text" />
<input name="norm[3]" type="checkbox" value="4">Participante en el Programa Banca de Desarrollo 
<input name="anio[3]" value="" type="text" /> 
y al pasar el arreglo anio por POST, lo puedes recorrer con un for, e ir obteniendo el valor que hay en la caja de texto correspondiente:

Código PHP:
$cedula$_GET['cedula']; 
$id$_GET['id']; 

if ((isset(
$_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) { 
     
    
$i=0
   
$sociales=""
     
foreach (
$_POST['id_progsocial'] as $social){ 
   
$id_progsocial[$i]=$social
   
$sociales="".$id_progsocial[$i].", ".$sociales.""
$insertSQL "INSERT IGNORE INTO rsptas_progsocial (identificacion, id_progsocial,  ano ) VALUES ('$cedula','".$sociales."', '{$_POST['anio[' . $i . ']']}' )"

     
$i++;

  
mysql_select_db($database_conexion$conexion); 
  
$Result1 mysql_query($insertSQL$conexion) or die(mysql_error()); 
}
      
$mensaje="Se ingreso correctamente el solicitante"
      
$prematricula=  '<td><a href="http://www.forosdelweb.com/f18/prematricula/prematricular.php?id='.$id.' & cedula='.$cedula.'">Prematricular</a></td></tr>';