Ver Mensaje Individual
  #7 (permalink)  
Antiguo 15/03/2011, 21:12
jonathan777
 
Fecha de Ingreso: marzo-2011
Ubicación: lima
Mensajes: 25
Antigüedad: 14 años
Puntos: 0
Respuesta: Pasar valor seleccionado de Select a variable php

Código PHP:
Ver original
  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
  2. <html>
  3.     <head>
  4.         <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  5.         <title></title>
  6.     </head>
  7.     <body>
  8.     <form name="form1" method="post" action="consulta.php">
  9.       Escriba usuario
  10.       <input type="text" name="txtUsuario" id="txtUsuario">
  11.     <input type="submit" name="btnEnviar" id="btnEnviar" value="Consultar">
  12.     </form>
  13. </body>
  14. </html>

Es el inicial
el segundo es
Código PHP:
Ver original
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3.     <head>
  4.         <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  5.         <title>Documento sin t&iacute;tulo</title>
  6.         <script src="SpryAssets/SpryTabbedPanels.js" type="text/javascript"></script>
  7.         <link href="SpryAssets/SpryTabbedPanels.css" rel="stylesheet" type="text/css" />
  8.         <style type="text/css">
  9.             <!--
  10.             .Estilo1 {
  11.                 font-size: 1em
  12.             }
  13.             -->
  14.         </style>
  15.     </head>
  16.     <?php
  17.     include 'conection.php';
  18.     $link = Conectarse();
  19.     $encon = false;
  20.     $varuser = $_POST['txtUsuario'];
  21.     $direccion = $_POST['transporte'];
  22.     $sql = "SELECT usuarios.nomb_usuarios, Razas.nomb_raza FROM usuarios INNER JOIN Razas ON usuarios.codi_raza = Razas.codi_raza where usuarios.nomb_usuarios = '$varuser'";
  23.     $resultado = mysql_query($sql, $link);
  24.     if ($fila = mysql_fetch_array($resultado)) {
  25. //Se verifica que el resultado no sea vacio
  26.         mysql_field_seek($resultado, 0);
  27.         while ($field = mysql_fetch_field($resultado)) {
  28.             //Verifica que la metadata sea la correcta y la captura
  29.         }
  30.         do {
  31.             /*
  32.               Con "$fila" mostramos los datos y
  33.               mostramos los registros
  34.              */
  35.             $txtusuario = $fila[0];
  36.             $txtRaza = $fila[1];
  37.             $encon = true;
  38.         } while ($fila = mysql_fetch_array($resultado));
  39.         if ($encon) {
  40.             $sql = "SELECT Numero_direccion, Galaxia FROM Direcciones where nomb_usuarios = '$varuser'";
  41.             $resultado = mysql_query($sql, $link);
  42.             while ($fila = mysql_fetch_array($resultado)) {
  43.                 //echo $fila[0];
  44.                 $variable = $fila[0];
  45.                 Agregar_Lista($variable);
  46.                 echo $variable;
  47.                 //echo $fila[1];
  48.             }
  49.         }
  50.     } else {
  51.         /*
  52.           Si no se encontraron resultados
  53.           se muestra el siguiente mensaje
  54.          */
  55.         echo "No se encontraron resultados!";
  56.         header("Location: index.php");
  57.         //Redirecciona al indice si Hubo error
  58.     }
  59.    
  60.  
  61.     function Agregar_Lista($parametro) {
  62.         global $variable_html;
  63.         $variable_html = $variable_html . " " . "<option value=''>" . $parametro . "</option>";
  64.     }
  65.  
  66.     function panel_tropas() {
  67.         //$sql = "";
  68.         global $direccion;
  69.         echo $direccion;
  70.     }
  71.  
  72.     function panel_naves() {
  73.  
  74.     }
  75.  
  76.     function panel_defensas() {
  77.  
  78.     }
  79.     ?>
  80.     <body>
  81.  
  82.         <form id="form1" name="form1" method="post" action="">
  83.             <label>Otras opciones</label>
  84.             <label>
  85.                 <select name="Menu_opcion" id="Menu_opcion">
  86.                     <option value="Menu_eliminar">Eliminar usuarios y sus datos</option>
  87.                     <option value="Menu_salir">Salir</option>
  88.                 </select>
  89.             </label>
  90.         </form>
  91.  
  92.         <form id="form4" name="form4" method="post" action="">
  93.  
  94.             Usuario&nbsp;&nbsp;&nbsp;
  95.             <input name="txtusuario" type="text" id="txtusuario" value=<?php echo $txtusuario ?> />
  96.             &nbsp; Raza&nbsp; &nbsp;
  97.             <input name="txtraza" type="text" id="txtraza" value=<?php echo $txtRaza ?> />
  98.             &nbsp; &nbsp; &nbsp;
  99.         </form>
  100.  
  101.         <form id="form5" name="form5" method="post" action="">
  102.             Direcciones
  103.         </form>
  104.         <form id="form6" name="form6" method="post" action="index.php">
  105.             <select name="transporte" size="5" onchange="document.form.submit();">
  106.                 <?php
  107.                 echo $variable_html;
  108.                 ?>
  109.             </select>
  110.                
  111.                 <input type="submit" name="btnAceptar" id="btnAceptar" value="Aceptar" />
  112.  
  113.             </form>
  114.             &nbsp;
  115.  
  116.             <div id="Panel_principal" class="TabbedPanels">
  117.                 <ul class="TabbedPanelsTabGroup">
  118.                     <li class="TabbedPanelsTab Estilo1" tabindex="0">Tropas</li>
  119.                     <li class="TabbedPanelsTab Estilo1" tabindex="0">Naves</li>
  120.                     <li class="TabbedPanelsTab Estilo1" tabindex="0">Defensas</li>
  121.                 </ul>
  122.                 <div class="TabbedPanelsContentGroup">
  123.                     <div class="TabbedPanelsContent">
  124.                         <form id="form2" name="form2" method="post" action="">
  125.                             Contenido 1
  126.                         <?
  127.                         echo panel_tropas();
  128.                         ?>
  129.                     </form>
  130.                 </div>
  131.                 <div class="TabbedPanelsContent">
  132.                     <form id="form3" name="form3" method="post" action="">
  133.                         Contenido 2
  134.                         <?
  135.                         echo panel_naves();
  136.                         ?>
  137.                     </form>
  138.                 </div>
  139.                 <div class="TabbedPanelsContent">
  140.                     <form id="form4" name="form4" method="post" action="">
  141.                         Contenido 3
  142.                         <?
  143.                         echo panel_defensas();
  144.                         ?>
  145.                     </form>
  146.                 </div>
  147.             </div>
  148.         </div>
  149.         <p>&nbsp;</p>
  150.         <p>&nbsp;</p>
  151.         <script type="text/javascript">
  152.             <!--
  153.             var TabbedPanels1 = new Spry.Widget.TabbedPanels("Panel_principal", {defaultTab:2});
  154.             //-->
  155.         </script>
  156.  
  157.     </body>
  158. </html>

Es una pequeña aplicacion de juego cada usuario tiene un id y una raza y otros atributos como tropas,naves y defensas.
Espero puedas indicarme que esta mal.
Gracias