PHP - Insertar formulario con select en tabla

 
Vista:
Imágen de perfil de Jorge Luis
Val: 27
Ha aumentado su posición en 69 puestos en PHP (en relación al último mes)
Gráfica de PHP

Insertar formulario con select en tabla

Publicado por Jorge Luis (7 intervenciones) el 26/09/2015 20:06:07
Buen dia! amigos, tengo una duda estoy realizando un formulario con dos campos de select dependientes, pero a la hora de guardar solo me guardar el primer select, el segundo no...

Ojala me puedan ayudar

este es mi 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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
<?php
session_start();
    new mysqli('167.100.2.32','sa','madmvw','servicios');
    $_SESSION["IdTecnico"]=$row['IdTecnico'];
    $_SESSION["nomcop"]=$row['nomcop'];
?>
 
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="es">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
        <title>Tiempos Muerto</title>
        <script type="text/javascript" src="jquery.min.js"></script>
        <style type="text/css">
            .body{
                background: #069;
 
            }
            .login{
                width: 400px;
                border-color: #FFF;
 
            }
            .label{
                font-size: 12px;
                font-family: Trebuchet;
                color: white;
            }
            .btn{
                border-radius: 10px;
            }
        </style>
        <script type="text/javascript">
            $(document).ready(function () {
                $("#paises").change(function () {
                    $.ajax({
                        url: "procesar.php",
                        type: "POST",
                        data: "pais=" + $("#paises").val(),
                        success: function (opciones) {
                            $("#tipo").html(opciones);
                        }
                    })
                });
            });
        </script>
    </head>
    <body class="body">
        <div align="right">
            <a href="salir.php" class="label">Cerrar Session</a>
        </div>
 
        <div align="center">
 
            <table>
                <?php
                    $con = new mysqli('167.100.2.32','sa','madmvw','servicios');
                    $Qry = "SELECT * FROM time_dead_tecnicos";
                    $res = $con->query($Qry);
                    $row = mysqli_fetch_assoc($res);
                ?>
                <?php
                  error_reporting(E_ALL ^ E_NOTICE);
                  if ($_POST['guardar']) {
                     // Proceso de Conexion a la Base
                    $link = new mysqli("167.100.2.32", "sa", "madmvw","servicios");
                    //Proceso de Inserccion
                    $idtec = $_POST['IdTecnico'];
                    $NomTec = $_POST['NomTec'];
                    $idemp = $_POST['IdEmpresa'];
                    $clase = $_POST['clase'];
                    $tipo = $_POST['tipo'];
                    $idfol = $_POST['IdFolio'];
                    $fecini = $_POST['FechaInicio'];
                    $fecfin = $_POST['FechaFin'];
 
                    $sql = ("INSERT INTO time_dead_mechanic (IdTecnico,NomTec,IdEmpresa,Clase,Tipo,IdFolio,FechaInicio,FechaFin)".
                      "VALUES ('$idtec', '$NomTec', '$idemp', '$clase', '$tipo', '$idfol', '$fecini', '$fecfin')");
                    $result = $link->query($sql);
                    echo "Gracias! Hemos recibido sus datos.";
                    header ("REFRESH: 1; URL=consultar.php");
                    }else{
                ?>
            <form method="POST" action="" name="form1">
                <h1>Tiempos Muertos</h1>
                <td><label>No. Tecnico:</td> <td><input type="" name="IdTecnico" value="<?php  echo $row['IdTecnico']; ?>" size="5"></td>
                <td><label>Nombre:</td> <td><input type="" name="NomTec" value="<?php echo $row['nomcomp']; ?>" size="25"></td>
                <td><label>Empresa:</td> <td><input type="" name="IdEmpresa" value="<?php echo $row['IdEmpresa']; ?>" size="1"></td>
            </table>
            <?php
                function generaPaises() {
                    //include 'conexion.php';
                    $con = new mysqli('167.100.2.32', 'sa', 'madmvw', 'servicios');
                    $consulta = $con->query("SELECT id, opcion FROM time_dead_clase");
                    //desconectar();
 
                    // Voy imprimiendo el primer select compuesto por los paises
                    while ($registro = mysqli_fetch_row($consulta)) {
                        echo "<option value='" . $registro[0] . "'>" . $registro[1] . "</option>";
                    }
                }
            ?>
            <table>
                <th>Clase</th>
                <th>Tipo</th>
                <th>Folio</th>
                <th>Fecha Inicio</th>
                <th>Fecha Fin</th>
                <tr>
                    <td>
                        <select name="clase" id="paises" />
                            <option value="0">Elige...</option>
                            <?php generaPaises(); ?>
                        </select>
                    </td>
                    <td>
                        <select name="tipo" id="tipo" />
                            <option value="0">Elige...</option>
                        </select>
                    </td>
                    <td>
                        <input type="text" name="IdFolio" size="2" />
                    </td>
                    <td>
                        <input type="" name="FechaInicio" value="" />
                    </td>
                    <td>
                        <input type="" name="FechaFin" value="">
                    </td>
                </tr>
 
            </table>
            <input type="submit" name="guardar" value="Registrar">
        </form>
        <?php
          }
        ?>
        </div>
        <div align="center">
            <?php
            $conex = new mysqli('167.100.2.32', 'sa', 'madmvw', 'servicios');
            $query = "select * from time_dead_mechanic ORDER BY IdTecnico";
 
            $resultado = $conex->query($query);
            ?>
            <table cellpadding="0" border="1" style="font-family:Trebuchet; size:12px; color:#FFF;">
                <tr>
                    <th>Id Tecnico</th>
                    <th>Nombre Tecnico</th>
                    <th>Empresa</th>
                    <th>Clase</th>
                    <th>Tipo</th>
                    <th>Id Folio</th>
                    <th>Fecha Inicio</th>
                    <th>Fecha Fin</th>
                    <th>Editar</th>
                </tr>
                <?php while ($row = mysqli_fetch_array($resultado)) { ?>
                    <tr>
                        <td>
                            <?php echo $row['IdTecnico']; ?>
                        </td>
                        <td>
                            <?php echo $row['NomTec']; ?>
                        </td>
                        <td>
                            <?php echo $row['IdEmpresa']; ?>
                        </td>
                        <td>
                            <?php echo $row['Clase']; ?>
                        </td>
                        <td>
                            <?php echo $row['Tipo']; ?>
                        </td>
                        <td>
                            <?php echo $row['IdFolio']; ?>
                        </td>
                        <td>
                            <?php echo $row['FechaInicio']; ?>
                        </td>
                        <td>
                            <?php echo $row['FechaFin']; ?>
                        </td>
                        <td>
                            <center><a href="modif_tiempo.php?IdTecnico=<?php echo $row['IdTecnico']; ?>"><img src="imagen/editar.png"></a></center>
                        </td>
                    </tr>
                <?php } ?>
            </table>
        </div>
    </body>
</html>
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