Ver Mensaje Individual
  #4 (permalink)  
Antiguo 09/02/2007, 20:21
Garmauco
 
Fecha de Ingreso: mayo-2006
Mensajes: 99
Antigüedad: 20 años, 5 meses
Puntos: 0
De acuerdo Re: checkbox como en phpmyadmin

Holas,, Amigos,,,, bueno he estado ensayando lo de modificar varios registros con checkbox...y esto es lo que llevo,. aun me falta lo de grabar los datos... si alguien quiere ayudarme a terminar el script pues se lo agradeceria...


Código PHP:
<?php require_once('Conn.php'); 
$maxReg = 10;
$Reg_ini = 0;

mysql_select_db($database_Conn, $Conn);
$sql = "SELECT id_usuario, usuario,telefono FROM usuarios";
$sql_limit = sprintf("%s LIMIT %d, %d", $sql, $Reg_ini, $maxReg);
$cursor = mysql_query($sql_limit, $Conn) or die(mysql_error());
$row = mysql_fetch_assoc($cursor);

if (isset(
$_GET['totalRegs'])) {
  
$totalRegs = $_GET['totalRegs'];
} else {
  
$all_Regs = mysql_query($sql);
  
$totalRegs= mysql_num_rows($all_Regs);
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Actualizacion con Checkbox</title>
</head>
<body>
<form id="form1" name="form1" method="post" action="prueba.php">
  <?php do { ?>
    <table width="80%">
      <tr>
      <td width="40%" ><?php echo $row['usuario']; ?> </td>
      <td width="49%" ><?php echo $row['telefono']; ?> </td>
      <td width="11%" >
      <label>
      <input type="checkbox" name="reg[<?php echo $row['id_usuario']; ?>]" value="reg[<?php echo $row['id_usuario']; ?>]" />
      </label></td>
    </tr>
          </table>
    <?php } while ($row= mysql_fetch_assoc($cursor)); ?>
    <br />
    <label>
    <input type="submit" name="enviar" value="Enviar" >
        

    </label>
</form>
</body>
</html>
<?php
if ($_POST['enviar'] == "Enviar"){
if(!empty(
$_POST['reg'])) { 
echo
"....";
echo
"<form name=gudr method=POST action='prueba.php'>";
     
$registros = array_keys($_POST['reg']); 
     
$registros = implode("','", $registros);
     
$registros = "'".$registros."'";
     
$sql1="SELECT * FROM usuarios WHERE id_usuario IN ($registros)";
    
$cursor1 = mysql_query( $sql1, $Conn );
    
$j=mysql_num_fields($cursor1); 
    
$k=mysql_num_rows($cursor1);
    echo
$k;
    
$i=1;
    while( 
$fila = mysql_fetch_array( $cursor1 ) ) {
              
$campo[0] = $fila[0];
              
$campo[1] = $fila[1];
              
$campo[2] = $fila[2];         
              echo
$campo[1];
              echo
"<p>ID: ";
              echo
"<input type= text name=id$i size=20 value='$campo[0]'>";
              echo
"</p>";
              echo
"<p>Nombre: ";
              echo
"<input type= text name=nmb$i size=20 value='$campo[1]'>";
              echo
"</p>";
              echo
"<p>Telefono: ";
              echo
"<input type= text name=tel$i size=20 value='$campo[2]'>";
              echo
"</p>";    
              echo
"<HR size=1 align=right width=100% color=7D889A>";                        
     
$i++;
    }

} 
}
mysql_free_result($cursor);
?>
__________________
El sabio puede sentarse en un hormiguero, pero sólo el necio se queda sentado en él

Última edición por Garmauco; 10/02/2007 a las 11:24