PHP - Select dependientes y php

 
Vista:
sin imagen de perfil

Select dependientes y php

Publicado por anonymous (41 intervenciones) el 29/08/2014 22:22:10
Que tal, tengo problemas con un select, no se como manejarlo la verdad, mi idea es esta haber si me explico:

Hay tres opciones de reporte, una de esas tres opciones manda directo al reporte, las otras dos necesitan otro dato.

Hasta ahorita llevo realizado como las tres opciones necesitaran otro dato, ahi el detalle como hacerlo que solo dos opciones me pidan un segundo select.

Otra es la pantalla que voy a direccionar dependiendo que opción seleccionaron, de este necesito el dato del primer select y del segundo, sonara facil poniendo $_POST['select1'] $_POST['select2'] pero al seleccionar el dato del select 1 hago un $_SERVER['PHP_SELF'], esto para que refresque y traiga nuevamente el formulario ya seleccionando el select previamente. Asi que cuando paso a la pantalla a ver el dato de $_POST[select1] este no esta disponible ya por el refresco.

esto es lo que llevo:

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
html
    <head>
        <title>Seleccionar Tipo de Reporte</title>
        <link rel="stylesheet" href="css1.css" media="all" />
    </head>
    <body>
        <div id="navbar">
            <span class="inbar">
                <ul>
                    <li><a href="index.php"><span>Inicio</span></a></li>
                    <li><a href="inputreporte.php"><span>Reportes</span></a></li>
                    <li><a href="#contact"><span>Contacto</span></a></li>
                    <li><a href="logout.php"><span>Salir</span></a></li>
                </ul>
            </span>
        </div>
        <?php
        $qfiltros = "select * from filtros";
        $conexion = mysqli_connect("localhost", "root", "root", "base1") or die("Problema en la conexion");
        $regqfiltros = mysqli_query($conexion, $qfiltros);
        $tip = -1;
 
        if (!empty($_POST['camposelect'])) {
            $tip = $_POST['camposelect'];
        }
        echo "<form name='form1' method='POST' action='" . $_SERVER['PHP_SELF'] . "'>";
        echo "<strong>Seleccionar Tipo de Reporte</strong>";
        echo "<select name='camposelect' size='1' onChange='this.form.submit()'>";
        echo "<option value='nada' selected>Seleccione...</option>";
        while ($regqf = mysqli_fetch_array($regqfiltros)) {
            if ($regqf[0] == $tip) {
                echo "<option value='" . $regqf[0] . "' selected>" . $regqf[1] . "</option>";
            } else {
                echo "<option value='" . $regqf[0] . "'>" . $regqf[1] . "</option>";
            }
        }
        echo "</select>";
        echo "</form>";
        echo $tip;
        $qtipo = "select tipo from filtros where id = " . $tip . "";
        $regqtipo = mysqli_query($conexion, $qtipo);
        $regqt = mysqli_fetch_array($regqtipo);
        echo "<form name='form2' action='procesamiento.php' method='POST'>";
        echo "<strong>Seleccione:</strong>";
        echo "<select name='2camposelect'>";
        echo "<option value='0'>Todas</option>";
        $qopcion = "select distinct(" . $regqt[0] . ") from julio14";
        $regqopcion = mysqli_query($conexion, $qopcion);
        while ($regqo = mysqli_fetch_array($regqopcion)) {
            echo "<option value='" . $regqo[0] . "'>" . $regqo[0] . "</option>";
        }
        echo "</select>";
        echo "<input type='submit' value='Enviar' name='accion'>";
        echo "</form>";
 
        ?>
    </body>
</html>

Y esto es lo de procesamiento.php

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
<?php
 
$var = $_POST['camposelect'];
echo $var;
switch ($_POST['accion']) {
    case "Importar a PDF":header("location: index_pdf.php");
        break;
    case "Importar a Excel":header("location: index_excel.php");
        break;
    case "Mandar Mail":header("location: index_mail.php");
        break;
    case "Enviar":
        switch ($_POST['camposelect']) {
            case 2:
                header("location:reportegpo.php");
                break;
            case 3:
                header("location:reportezona.php");
                break;
            case 4:
                header("location:reportetienda.php");
                break;
        }
}
?>
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

Select dependientes y php

Publicado por anonymous (41 intervenciones) el 30/08/2014 00:20:11
solucionado con $_SESSION
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