Ver Mensaje Individual
  #4 (permalink)  
Antiguo 31/08/2011, 00:31
Avatar de edgar_cln
edgar_cln
 
Fecha de Ingreso: agosto-2010
Ubicación: Sierra Sinaloense
Mensajes: 122
Antigüedad: 13 años, 8 meses
Puntos: 4
Respuesta: checked y accesos

o algo del insert estara mal? ... el Delete me lo imprime bien mas el insert no me lo imprime e ahi el problema ... tendre que declarar variables .. sera acaso eso?'

este es todo mi codigo en el archivo...algo a de tar mal pero la neta no encuentro que es .. :S:S:S porfass !!
Código PHP:
Ver original
  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
  2. <html>
  3. <head>
  4. <title>Accesos</title>
  5. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  6. <link href="styles/estilo1.css" rel="stylesheet" type="text/css">
  7. <link href="styles/estilo2.css" rel="stylesheet" type="text/css">
  8. <style type="text/css">
  9. <!--
  10. .Estilo1 {
  11.     color: #FFFFFF;
  12.     font-weight: bold;
  13. }
  14. -->
  15. </style>
  16. </head>
  17.  
  18. <body>
  19. <?
  20. require_once("conectar.php");
  21. $link=conectar();
  22.  
  23. if(isset($_POST[btn_registrar])){
  24.         $sl_usuario = $_POST['sl_usuario'];
  25.                 $ids = $_POST['ids'];
  26.  
  27. $sqlDelete="delete from accesos where id_usuario='$_POST[sl_usuario]'";
  28. echo "$sqlDelete";
  29. mysql_query($sqlDelete,$link);
  30.  
  31.     for($i=1;$i<=$h_contador;$i++){
  32.             $ids="ch_".$i;
  33.                 if($$ids){
  34.                 //echo $ids."<br>";
  35.                 $sql="insert into accesos set
  36.                 id_usuario='$_POST[sl_usuario]',
  37.                 id_modulo='".$$ids."'";
  38.                 echo "<br>$sql<br>";
  39.                 mysql_query ($sql,$link) or die($sql);
  40.             }
  41.  
  42.     }
  43. }
  44. ?>
  45. <a href="login_success.php"><img src="menu.jpg" width="126" height="30" border="0"></a>
  46. <form name="form1" method="post" action="">
  47.   <p>&nbsp;</p>
  48.   <div align="center"></div>
  49.   <table width="400" height="23" border="0" align="center">
  50.     <tr>
  51.       <td bgcolor="#146389"><div align="center" class="Estilo1">ACCESOS</div></td>
  52.     </tr>
  53.   </table>
  54.   <table width="400" height="23" border="0" align="center">
  55.     <tr class="tables">
  56.       <td width="114"><div align="right"><strong>Empleado:</strong></div></td>
  57.       <td width="326" rowspan="2"><div align="center">
  58.         <select name="sl_usuario" class="tables" id="select8"onChange="document.form1.submit()">
  59.             <option value="0" <? if ($_POST[sl_usuario]==0) echo "selected";?>>Seleccionar</option>
  60.             <? $sqlc="Select id,concat(nombre,' ',ape_pat,' ',ape_mat) as nom
  61.                         from usuarios
  62.                         order by nom";
  63.         //echo $sqlc;
  64.         $resc=mysql_query($sqlc,$link);
  65.         //echo "<br>".mysql_num_rows($resc);
  66.         while($rowc=mysql_fetch_object($resc)){
  67.         ?>
  68.             <option value="<?=$rowc->id?>" <? if($_POST[sl_usuario]==$rowc->id) echo "selected";?> >
  69.             <?=$rowc->nom?>
  70.             </option>
  71.             <? } ?>
  72.         </select>
  73.       </div></td>
  74.     </tr>
  75.     <tr class="tables">
  76.       <td><?
  77.     $sql="select modulos.descripcion,modulos.id as menu,modulos.imagen,
  78.     (select id_usuario from accesos where id_usuario=$_POST[sl_usuario] and id_modulo=modulos.id) as acceso
  79.                 from modulos
  80.                 inner join menus on modulos.id_menu=menus.id
  81.                 left join accesos on modulos.id=accesos.id_modulo
  82.                 group by modulos.descripcion
  83.                 order by modulos.descripcion";
  84. //echo $sql;
  85. $res=@mysql_query($sql,$link);
  86. $con=0;
  87. while($row=@mysql_fetch_object($res)){
  88. $con++;
  89. ?></td>
  90.     </tr>
  91.   </table>
  92.   <table width="400" height="23" border="0" align="center">
  93.     <tr>
  94.       <td bgcolor="#146389"><div align="center">
  95.         <blockquote>
  96.           <blockquote>
  97.             <blockquote>
  98.               <p align="left">&nbsp;&nbsp;<img src="menu/<?=$row->imagen?>" width="32" height="32">
  99.                   <input type="checkbox" name="ch_<?=$con?>" value="<?=$row->menu?>" <? if($row->acceso>0){ ?>checked<? }?>>
  100.                   <?=$row->descripcion?>  
  101.                 </p>
  102.             </blockquote>
  103.           </blockquote>
  104.         </blockquote>
  105.       </div>      </td>
  106.       <? } ?>
  107.     </tr>
  108.     <tr>
  109.       <td><div align="center" class="tables">
  110.         <input name="btn_registrar" type="submit" id="btn_registrar7" value="Registrar" <? if($_POST[sl_usuario]<=0) echo"disabled";?> style="width:130px" >
  111.         <input name="h_contador" type="hidden" id="h_contador7" value="<?=$con?>">
  112.       </div></td>
  113.     </tr>
  114.   </table>
  115.  
  116. </form>
  117. </body>
  118. </html>

Última edición por edgar_cln; 31/08/2011 a las 00:48