PHP - 3 INCLUDE con radio boton PHP y JAVASCRIPT

 
Vista:

3 INCLUDE con radio boton PHP y JAVASCRIPT

Publicado por Marisol (1 intervención) el 12/08/2018 01:02:55
Mediante una serie de RADIO BOTON realizo 3 llamados a FUNCIONES para que se habiliten o deshabiliten ciertos archivos de los cuales llamo con INCLUDE, me selecciona correctamente, pero mi problema es que solo graba en la base de datos el ultimo INCLUDE... No se que le puede estar faltando para que logre salvar esos registros.... Estoy muy preocupada, les ruego me den una manito con este codigo.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
<table width="100%" border="0" cellpadding="0" cellspacing="0" bordercolor="#F0F0F0" >
 
<td width="26%"></strong>
 
<label>
 <input value="1" <?php $filas_t['id_cdu']; ?> name="id_cdu"  id="radio1" type="radio"onClick="residencial_f()" >Residencial</label>
   <br>
<label>
 <input value="2" <?php $filas_t['id_cdu']; ?> name="id_cdu" id="radio2" type="radio" onClick="multiusuario_f()" >
Multiusuario</label>
  <br>
<label>
 <input value="3" <?php $filas_t['id_cdu']; ?> name="id_cdu" id="radio3" type="radio" onClick="varios_f()" >
Comercial</label>
   <br>
<label>
 <input value="4" <?php $filas_t['id_cdu']; ?> name="id_cdu" id="radio4" type="radio" onClick="varios_f()" >
Especial</label>
   <br>
<label>
 <input value="5" <?php $filas_t['id_cdu']; ?> name="id_cdu" id="radio5" type="radio" onClick="varios_f()" >
Oficial</label>
   <br>
<label>
  <input value="6" <?php $filas_t['id_cdu']; ?> name="id_cdu" id="radio6" type="radio" onClick="varios_f()" >
Industrial</label></td>
 
<script>
function residencial_f()
{
       document.getElementById("residencial").style.display='block';
	   document.getElementById("multiusuario").style.display='none';
       document.getElementById("varios").style.display='none';
 
	   document.getElementById("radio1").checked = true;
       document.getElementById("radio2").checked = false;
	   document.getElementById("radio3").checked = false;
	   document.getElementById("radio4").checked = false;
	   document.getElementById("radio5").checked = false;
	   document.getElementById("radio6").checked = false;
}
 
function multiusuario_f()
{
       document.getElementById("residencial").style.display='none';
       document.getElementById("multiusuario").style.display='block';
       document.getElementById("varios").style.display='none';
 
	   document.getElementById("radio1").checked = false;
       document.getElementById("radio2").checked = true;
	   document.getElementById("radio3").checked = false;
	   document.getElementById("radio4").checked = false;
	   document.getElementById("radio5").checked = false;
	   document.getElementById("radio6").checked = false;
}
 
function varios_f()
{
       document.getElementById("residencial").style.display='none';
       document.getElementById("multiusuario").style.display='none';
       document.getElementById("varios").style.display='block';
 
       document.getElementById("radio1").checked = false;
       document.getElementById("radio2").checked = false;
	   document.getElementById("radio3").checked = true;
	   document.getElementById("radio4").checked = true;
	   document.getElementById("radio5").checked = true;
	   document.getElementById("radio6").checked = true;
}
</script>
 
<td width="48" colspan="3">
 
 
<div id="residencial" style="display:none">
      <?php  include 'residencial.php'; ?>
</div>
 
<div id="multiusuario" style="display:none">
      <?php  include 'multiusuario.php'; ?>
</div>
 
<div id="varios" style="display:none">
      <?php  include 'varios.php'; ?>
</div>                </tr>
                 <tr>
                   <td colspan="3"></td>
                </tr>
             </table>


*******************************************************************************************************
INCLUDE RESIDENCIAL
*******************************************************************************************************
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
<table width="100%" border="0" cellpadding="0" cellspacing="0" bordercolor="#F0F0F0" >
  <tr>
    <td colspan="2">&nbsp;</td>
    <td width="68%" bgcolor="#EDF7FC"> Tipo de Punto:</td>
  </tr>
  <tr>
    <!---- Combobox UH Y TP ------>
    <td width="8%" align="right">UH:</td>
    <td width="24%">
 
    <select name="id_uh" id="id_uh" >
      <!---- COMBOX UH ------------------------------------------------------->
      <?php
        	$query_uh = "SELECT * FROM tbl_uh WHERE id_uh>=1";
		    $cons_uh = mysqli_query($conexion, $query_uh) or die ( "Algo ha ido mal en la consulta de la BD");
		    $fila_uh = mysqli_fetch_assoc($cons_uh);
      ?>
      <option value="0" selected>Seleccione..</option>
      <?php
	     do {
      ?>
         <option value="<?php echo $fila_uh['id_uh']?>"
		   <?php if (!(strcmp($fila_uh['id_uh'], $fila_uh['id_uh']))) ?> >
		   <?php echo $fila_uh['num_uh']?>
         </option>
      <?php
			    }
			    while ($fila_uh = mysqli_fetch_assoc($cons_uh));
				$rows = mysqli_num_rows($cons_uh);
		    	if($rows > 1)
				{
				    mysqli_data_seek($cons_uh, 1);
				    $fila_uh = mysqli_fetch_assoc($cons_uh);
   				}
			    /// FIN QUERY tabla UH -----------------------------------------------------------------	
	 ?>
     </select>
 
    </td>
    <td width="68%" rowspan="2" bgcolor="#D2EBF7">
 
      <select name="id_tp" id="id_tp">
        <!---- COMBOX TP ------------------------------------------------------->
        <?php
     		$query_tp = "SELECT * FROM tbl_tp WHERE ruh=1";
	        $cons_tp = mysqli_query($conexion, $query_tp) or die ( "Algo ha ido mal en la consulta de la BD");
	        $fila_tp = mysqli_fetch_assoc($cons_tp);
	    ?>
        <option value="0" selected>Seleccione..</option>
        <?php
	       do {
	    ?>
        <option value="<?php echo $fila_tp['id_tp']?>"
			 <?php if (!(strcmp($fila_tp['id_tp'], $fila_tp['id_tp']))) ?> >
			 <?php echo $fila_tp['id_tp']?> <?php echo $fila_tp['nom_tp']?>
		</option>
        <?php
			  }
			   while ($fila_tp = mysqli_fetch_assoc($cons_tp));
			   $rows = mysqli_num_rows($cons_tp);
			   if($rows > 1)
			   {
				   mysqli_data_seek($cons_tp, 1);
				   $fila_tp = mysqli_fetch_assoc($cons_tp);
     		   }
 
	   ?>
       </select>
 
    </td>
  </tr>
  <tr>
    <td align="right">UNH:</td>
    <td>
        <input name="id_unh" type="hidden" id="id_unh" value="777" ></td>
  </tr>
 
</table>

*******************************************************************************************************
INCLUDE MULTIUSUARIO
*******************************************************************************************************
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
<table width="100%" border="0" cellpadding="0" cellspacing="0" bordercolor="#F0F0F0" >
  <tr>
    <td colspan="2">&nbsp;</td>
    <td width="68%" bgcolor="#EDF7FC"> Tipo de Punto:</td>
  </tr>
  <tr>
    <!---- Combobox UH Y TP ------>
    <td width="8%" align="right">UH:</td>
    <td width="24%">
 
    <select name="id_uh" id="id_uh" >
      <!---- COMBOX UH ------------------------------------------------------->
      <?php
 
 
   			$query_uh2 = "SELECT * FROM tbl_uh WHERE id_uh>=1";
	        $cons_uh2 = mysqli_query($conexion, $query_uh2) or die ( "Algo ha ido mal en la consulta de la BD");
	        $fila_uh2 = mysqli_fetch_assoc($cons_uh2);
      ?>
      <option value="" selected="selected">Seleccione..</option>
      <?php
	       do {
      ?>
      <option value="<?php echo $fila_uh2['id_uh']?>"
		   <?php if (!(strcmp($fila_uh2['id_uh'], $fila_uh2['id_uh']))) ?> >
		   <?php echo $fila_uh2['num_uh']?>
      </option>
      <?php
		    }
		    while ($fila_uh2 = mysqli_fetch_assoc($cons_uh2));
			$rows = mysqli_num_rows($cons_uh2);
			if($rows > 0)
			{
	     	    mysqli_data_seek($cons_uh2, 0);
  		        $fila_uh2 = mysqli_fetch_assoc($cons_uh2);
   			}
			/// FIN QUERY tabla UH -----------------------------------------------------------------
			//$mysqli->close(); // Libera la memoria ocupada por el resultado		
    ?>
    </select>
 
    </td>
    <td width="68%" rowspan="2" bgcolor="#D2EBF7">
 
    <select name="id_tp" id="id_tp" >
      <!---- COMBOX TP ------------------------------------------------------->
      <?php
   			$query_tp2 = "SELECT * FROM tbl_tp WHERE muh=1";
	        $cons_tp2 = mysqli_query($conexion, $query_tp2) or die ( "Algo ha ido mal en la consulta de la BD");
	        $fila_tp2 = mysqli_fetch_assoc($cons_tp2);
      ?>
 
      <option value="" selected="selected">Seleccione..</option>
 
	  <?php
	       do {
       ?>
      <option value="<?php echo $fila_tp2['id_tp']?>"
		   <?php if (!(strcmp($fila_tp2['id_tp'], $fila_tp2['id_tp']))) ?> >
		   <?php echo $fila_tp2['id_tp']?> <?php echo $fila_tp2['nom_tp']?>
      </option>
      <?php
		    }
		    while ($fila_tp2 = mysqli_fetch_assoc($cons_tp2));
			$rows = mysqli_num_rows($cons_tp2);
			if($rows > 0)
			{
			    mysqli_data_seek($cons_tp2, 0);
			    $fila_tp2 = mysqli_fetch_assoc($cons_tp2);
     		}
		    /// FIN QUERY tabla TP -----------------------------------------------------------------	
			//$mysqli->close(); // Libera la memoria ocupada por el resultado	
	   ?>
       </select>
 
       </td>
  </tr>
  <tr>
    <td align="right">UNH:</td>
    <td>
 
    <select name="id_unh" id="id_unh" >
      <!---- COMBOX UNH ------------------------------------------------------->
      <?php
       		$query_unh2 = "SELECT * FROM tbl_unh WHERE id_unh>=1";
		    $cons_unh2 = mysqli_query($conexion, $query_unh2) or die ( "Algo ha ido mal en la consulta de la BD");
		    $fila_unh2 = mysqli_fetch_assoc($cons_unh2);
      ?>
      <option value="" selected="selected">Seleccione..</option>
      <?php
	      do {
      ?>
      <option value="<?php echo $fila_unh2['id_unh']?>"
		   <?php if (!(strcmp($fila_unh2['id_unh'], $fila_unh2['id_unh']))) ?> >
		   <?php echo $fila_unh2['num_unh']?>
      </option>
      <?php
		    }
		    while ($fila_unh2 = mysqli_fetch_assoc($cons_unh2));
			$rows = mysqli_num_rows($cons_unh2);
			if($rows > 0)
			{
			    mysqli_data_seek($cons_unh2, 0);
			    $fila_unh2 = mysqli_fetch_assoc($cons_unh2);
     		}
		    /// FIN QUERY tabla UNH -----------------------------------------------------------------	
			//$mysqli->close(); // Libera la memoria ocupada por el resultado	
	   ?>
    </select>
    </td>
  </tr>
</table>

*******************************************************************************************************
INCLUDE VARIOS
*******************************************************************************************************

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
<table width="100%" border="0" cellpadding="0" cellspacing="0" bordercolor="#F0F0F0" >
  <tr>
    <td colspan="2">&nbsp;</td>
    <td width="68%" bgcolor="#EDF7FC"> Tipo de Punto:</td>
  </tr>
  <tr>
    <!---- Combobox UH Y TP ------>
    <td width="8%" align="right">UH:</td>
    <td width="24%">
 
    <input name="id_uh" type="hidden" id="id_uh" value="0" ></td>
 
    <td width="68%" rowspan="2" bgcolor="#D2EBF7">
 
    <select name="id_tp" id="id_tp" >
      <!---- COMBOX TP ------------------------------------------------------->
      <?php
 
           $query_tp3 = "SELECT * FROM tbl_tp WHERE muh=1";
		   $cons_tp3 = mysqli_query($conexion, $query_tp3) or die ( "Algo ha ido mal en la consulta de la BD");
		   $fila_tp3 = mysqli_fetch_assoc($cons_tp3);
       ?>
      <option value="" selected="selected">Seleccione..</option>
      <?php
	       do {
      ?>
      <option value="<?php echo $fila_tp3['id_tp']?>"
		   <?php if (!(strcmp($fila_tp3['id_tp'], $fila_tp3['id_tp']))) ?> >
		   <?php echo $fila_tp3['id_tp']?> <?php echo $fila_tp3['nom_tp']?>
      </option>
      <?php
		   }
		   while ($fila_tp3 = mysqli_fetch_assoc($cons_tp3));
		   $rows = mysqli_num_rows($cons_tp3);
		   if($rows > 0)
		   {
			    mysqli_data_seek($cons_tp3, 0);
			    $fila_tp3 = mysqli_fetch_assoc($cons_tp3);
     	   }
			 /// FIN QUERY tabla TP -----------------------------------------------------------------	
		   //$mysqli->close(); // Libera la memoria ocupada por el resultado	 
	  ?>
      </select>
 
      </td>
  </tr>
  <tr>
    <td align="right">UNH:</td>
    <td>
 
    <select name="id_unh" id="id_unh" >
      <!---- COMBOX UNH ------------------------------------------------------->
      <?php
 
        	$query_unh3 = "SELECT * FROM tbl_unh WHERE id_unh>=1";
		    $cons_unh3 = mysqli_query($conexion, $query_unh3) or die ( "Algo ha ido mal en la consulta de la BD");
		    $fila_unh3 = mysqli_fetch_assoc($cons_unh3);
      ?>
      <option value="" selected="selected">Seleccione..</option>
      <?php
	     do {
      ?>
      <option value="<?php echo $fila_unh3['id_unh']?>"
		   <?php if (!(strcmp($fila_unh3['id_unh'], $fila_unh3['id_unh']))) ?> >
		   <?php echo $fila_unh3['num_unh']?>
      </option>
      <?php
		    }
		    while ($fila_unh3 = mysqli_fetch_assoc($cons_unh3));
			$rows = mysqli_num_rows($cons_unh3);
			if($rows > 0)
			{
			    mysqli_data_seek($cons_unh3, 0);
			    $fila_unh3 = mysqli_fetch_assoc($cons_unh3);
     		}
		    /// FIN QUERY tabla UNH -----------------------------------------------------------------	
			//$mysqli->close(); // Libera la memoria ocupada por el resultado
	   ?>
    </select>
    </td>
  </tr>
</table>
]
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder
sin imagen de perfil
Val: 729
Bronce
Ha aumentado 1 puesto en PHP (en relación al último mes)
Gráfica de PHP

3 INCLUDE con radio boton PHP y JAVASCRIPT

Publicado por Gonzalo (615 intervenciones) el 13/08/2018 06:00:02
Buenos dias Marisol.

en donde mandas el update o el insert?

el query esta ... algo complicado de entender

$query_unh3 = "SELECT * FROM tbl_unh WHERE id_unh>=1";

estas pidiendo cualquier registro que tenga un id mayor o igual a 1?

me parecería que mandas llamar toda la tabla excepto el id cero.

tu logica es ... diferente, no entiendo cual registro es el que vas a actualizar, parece ser que le pides "cualquier registro que no tenga Id igual a cero lo cual me deja con este query.

$query_unh3 = "SELECT * FROM tbl_unh WHERE id_unh>0";

a menos que tengas solo 1 registro en la tabla, solo asi tendría mas o menos sentido.

te recomiendo que hagas el cambio de mysqli a PDO.

has pensado en usar jquery en lugar de javascript nativo? a mi se me hace mucho mas facil actualizar objetos usando jquery.
salu2!
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar