Ver Mensaje Individual
  #1 (permalink)  
Antiguo 28/03/2014, 17:04
Avatar de Landa11
Landa11
 
Fecha de Ingreso: febrero-2014
Ubicación: En algún lugar de mi oficina
Mensajes: 148
Antigüedad: 10 años, 2 meses
Puntos: 1
Exclamación Tomar valores pasando el número 9

Hola tengo una duda con respecto al tomar el valor de ciertas variables, cuando hago una modificación masiva de todos mis datos de varios usuarios y los quiero modificar, me deja pero sólo hasta llegar al número 9, pasando de ese numero me da el mismo resultado y me dice que no hay valores seleccionados.

Cómo puedo tomar los valores del 10, 11, 12 y así sucesivamente.

Les dejo unos pantallazos y/o el código para que me puedan auxiliar.

Gracias

Código PHP:
Ver original
  1. <?php
  2. $con = mysql_connect("localhost", "root", "");
  3. if (! $con)
  4. {
  5.     die ("ERROR EN LA CONEXION CON MYSQL: ".mysql_error());
  6. }
  7.  
  8. $base = mysql_select_db("almacenaje",$con);
  9. if(! $base)
  10. {
  11.     die ("ERROR AL CONECTAR CON LA BASE DE DATOS: ".mysql_error());
  12.        
  13. }
  14.  
  15. $sql = "SELECT * FROM datos";
  16. $resultado = mysql_query($sql);
  17.  
  18. echo "<html>
  19.         <h1>MODIFICAR Y/O ELIMINAR</h1>
  20.         <body>
  21.         <form name='ejecuta' method='post' action='ejecuta.php'>
  22.             <table>
  23.                 <tr><td>Id</td><td>Nombre</td><td>Password</td><td>Correo Electronico</td><td>Modificar</td><td>Eliminar</td></tr>";
  24. $i = 0 ;
  25. while ($row = mysql_fetch_row($resultado)){
  26.             echo "<tr><td><input type='hidden' name='iduser[$i]' value='".$row[0]."'/>".$row[0]."</td>
  27.                       <td><input type='text' name='user[$i]' value='".$row[1]."'/>".$row[1]."</td>
  28.                       <td><input type='text' name='pass[$i]' value='".$row[2]."'/>".$row[2]."</td>
  29.                       <td><input type='mail' name='mail[$i]' value='".$row[3]."'/>".$row[3]."</td>
  30.                       <td><input type='radio' name='seleccion[$i]' value='modifica".$row[0]."'>".$row[0]."</td><!-- Esta línea es para saber si se modifica -->
  31.                       <td><input type='radio' name='seleccion[$i]' value='elimina".$row[0]."'>".$row[0]."</td><!-- Esta línea es para saber si se elimina -->
  32.                       </tr>";$i++;
  33. }
  34. echo "</table><input type='submit' value='Enviar'></form></body></html>";
  35. ?>


Código PHP:
Ver original
  1. <?php
  2. $con = mysql_connect("localhost" , "root", "");
  3. if (! $con)
  4. {
  5.     die ("ERROR EN LA CONEXION CON MYSQL: ".mysql_error());
  6. }
  7.  
  8. $base = mysql_select_db ("almacenaje",$con);
  9. if(! $base)
  10. {
  11.     die ("ERROR AL CONECTAR CON LA BASE DE DATOS: ".mysql_error());
  12. }
  13.  
  14. foreach ($_POST['seleccion'] as $indice => $valor)
  15. {
  16. $opcion = substr ($_POST['seleccion'][$indice],0,-1);
  17. switch($opcion)
  18. {
  19.     case 'modifica':$sql="UPDATE datos SET
  20.                           user='".$_POST['user'][$indice]."',
  21.                           pass='".$_POST['pass'][$indice]."',
  22.                           pass='".strip_tags(sha1($_POST['pass'][$indice]))."',
  23.                           mail='".$_POST['mail'][$indice]."'
  24.                           WHERE iduser=".$_POST['iduser'][$indice];break;
  25.     case 'elimina':$sql="DELETE FROM datos WHERE iduser=".$_POST['iduser'][$indice];break;
  26.     default: echo "<center>NO HAY NADA SELECCIONADO</center>"; break;
  27. }
  28. echo "<center><h3>Variable sql: ".$sql. "</center></h3>";
  29. $resultado = mysql_query($sql);
  30. if (! $resultado ){die ("ERROR AL EJECUTAR LA CONSULTA ".$_POST['seleccion'].":".mysql_error());}
  31. else{
  32.     echo "<center>SENTENCIA EJECUTADA CORRECTAMENTE</center><br />";
  33. }
  34. }
  35. ?>
  36. <html>
  37. <head>
  38. <body>
  39. <form action="principal.php" method="post">
  40. <center><input type="submit" name="button" value="Regresar a página principal" formaction="principal.php"></center>
  41. <br>
  42. <form action="terminado.php" method="post">
  43. <center><input type="submit" name="button" value="Terminar sesión" formaction="terminado.php"></center>
  44. </body>
  45. </head>
  46. </html>
__________________
Ayudando a la gente con nuestros códigos para poder tener el conocimiento adecuado y ser libres!