Tema: foreach
Ver Mensaje Individual
  #1 (permalink)  
Antiguo 04/11/2010, 15:35
visona
 
Fecha de Ingreso: febrero-2008
Mensajes: 675
Antigüedad: 16 años, 3 meses
Puntos: 5
foreach

No consigo saber como usar foreach en este caso.
Este es el form
Código PHP:
<form id="infantil" name="infantil" method="POST" action="<?php echo $editFormAction?>">
      <?php do { ?>  <table width="100%" border="0" cellspacing="5" class="form_liga">
       <tr>
        <td width="37%"><?php echo $row_equipos['linfantil']; ?></td>
        <td width="15%"><label> Favor:
         <input name="favor" type="text" id="favor" value="0" size="2" />
        </label></td>
        <td width="15%">Contra:
         <input name="contra" type="text" id="contra" value="0" size="2" /></td>
        <td width="25%">Puntos
         <input name="puntos" type="text" id="puntos" value="0" size="2" />
         <input name="equipo[]" type="hidden" id="equipo[]" value="<?php echo $row_equipos['linfantil']; ?>" />
         <input name="categoria" type="hidden" id="categoria" value="<?php echo $row_equipos['categoria']; ?>" /></td>
        <td width="8%">&nbsp;</td>
       </tr>
      </table> <?php } while ($row_equipos mysql_fetch_assoc($equipos)); ?>
      <input type="hidden" name="MM_insert" value="infantil" />
    
     <input type="submit" name="button" id="button" value="Enviar" />
     </form>
Y aqui la insercion
Código PHP:
foreach($_POST['equipo'] as $key => $valor) {
  
$insertSQL sprintf("INSERT INTO clasificacion (categoria_clasi, favor_clasi, contra_clasi, puntos_clasi, equipo_clasi) VALUES (%s, %s, %s, %s, %s)",
                       
GetSQLValueString($_POST['categoria'], "text"),
                       
GetSQLValueString($_POST['favor'], "int"),
                       
GetSQLValueString($_POST['contra'], "int"),
                       
GetSQLValueString($_POST['puntos'], "int"),
                       
GetSQLValueString($valor"text")) 
Solo me inserta el "equipo" y la "categoria" pero no los 3 campos restantes.