Menús de texto de múltiples opciones

  • 283banfil
  • Newbie
  • Newbie
  • No Avatar
  • Registrado: Sep 10, 2009
  • Mensajes: 6
  • Status: Offline

Nota Septiembre 10th, 2009, 2:20 pm

Im perplejo. Ive intentado todo en la web que me pueda encontrar. Tengo una lista de opciones múltiples del menú que cuando hago clic en enviar, sólo se considera la última opción. Yo puedo elegir las 3 opciones y sólo se opta por la última. PLEASE HELP!!
Mi código está abajo. Muchas gracias. Im tan frustrado, y asegurarse de que sus Im un arreglo fácil. Ive intentado sacar también las opciones de una base de datos MySQL, y puede tirar de la multa opciones, la que no puedo tener a mis desplegar múltiples bases de datos.
Código: [ Select ]

<head>
</head>

<body>
<form id="form1" name="form1" method="POST" action="/data/oe/hsa/form.php?">
 
<label>Providers
<select name="providers[]" size="4" multiple="TRUE" id="providers">
 <option value="Select">Select up to two options</option>
  <option value="1">BlueCross BlueShield</option>
  <option value="2">HealthPartners</option>

  <option value="3">PreferredOne</option>
 </select>
</label>
<p>
 <label>Submit
  <input type="submit" name="submit" id="submit" value="Submit" />
  </label>
  <br />
 
<input type="hidden" name="MM_insert" value="form1" />
</form>

</body>
</html>
  1. <head>
  2. </head>
  3. <body>
  4. <form id="form1" name="form1" method="POST" action="/data/oe/hsa/form.php?">
  5.  
  6. <label>Providers
  7. <select name="providers[]" size="4" multiple="TRUE" id="providers">
  8.  <option value="Select">Select up to two options</option>
  9.   <option value="1">BlueCross BlueShield</option>
  10.   <option value="2">HealthPartners</option>
  11.   <option value="3">PreferredOne</option>
  12.  </select>
  13. </label>
  14. <p>
  15.  <label>Submit
  16.   <input type="submit" name="submit" id="submit" value="Submit" />
  17.   </label>
  18.   <br />
  19.  
  20. <input type="hidden" name="MM_insert" value="form1" />
  21. </form>
  22. </body>
  23. </html>
  • Anonymous
  • Bot
  • No Avatar
  • Registrado: 25 Feb 2008
  • Mensajes: ?
  • Loc: Ozzuland
  • Status: Online

Nota Septiembre 10th, 2009, 2:20 pm

  • UPSGuy
  • Lurker ಠ_ಠ
  • Web Master
  • Avatar de Usuario
  • Registrado: Jul 25, 2005
  • Mensajes: 2735
  • Loc: Nashville, TN
  • Status: Offline

Nota Septiembre 10th, 2009, 2:38 pm

Youre que va a recibir una matriz en el lado del servidor. ¿Cómo está el procesamiento de parámetros (lo que le lleva a creer que sólo recibe el último resultado)? ¿Podríamos ver el fragmento de código de procesamiento?
I'd love to change the world, but they won't give me the source code.
  • 283banfil
  • Newbie
  • Newbie
  • No Avatar
  • Registrado: Sep 10, 2009
  • Mensajes: 6
  • Status: Offline

Nota Septiembre 11th, 2009, 4:48 am

En realidad estoy recibiendo una matriz, mi error. Im que consigue la palabra "arreglo" en mi base de datos mysql! ¿Qué significa que mi parámetros de procesamiento? Soy bastante nuevo en esto. Obviamente, algo Im que falta!! Algún otro código que escribí fue de procesamiento última opción, se trata de la tramitación de la palabra "serie".
Este es el código que debe hacer lo mismo, pero es el código que arroja sólo la última opción. Sus decisiones de retirarse de una base de datos, obviamente.

<select name="providers[]" size="4" multiple="TRUE" id="providers">
<option value="Select"> Seleccione un máximo de dos opciones </ option>
<? php
do (
?>
<option value = "<? php echo $ row_providers [" AutoID "]?>"><? php echo $ row_providers [ "proveedor de "]?></ option>
<? php
) While ($ row_providers = mysql_fetch_assoc ($ proveedores));
$ rows = mysql_num_rows ($ proveedores);
if ($ filas> 0) (
mysql_data_seek ($ proveedores, 0);
row_providers $ = mysql_fetch_assoc ($ proveedores);
)
?>
</ select>
  • UPSGuy
  • Lurker ಠ_ಠ
  • Web Master
  • Avatar de Usuario
  • Registrado: Jul 25, 2005
  • Mensajes: 2735
  • Loc: Nashville, TN
  • Status: Offline

Nota Septiembre 11th, 2009, 5:17 am

Eso significa que usted está recibiendo todas sus opciones en el otro lado. Im PHP asumiendo, pero si usted está usando otro idioma, probablemente me puede ayudar con eso, también. Intente algo así en su código:

Código: [ Select ]
$providerArr = $_POST['providers'];
foreach ($providerArr as $provider) {
   echo $provider."<br>\n";
}
  1. $providerArr = $_POST['providers'];
  2. foreach ($providerArr as $provider) {
  3.    echo $provider."<br>\n";
  4. }
I'd love to change the world, but they won't give me the source code.
  • 283banfil
  • Newbie
  • Newbie
  • No Avatar
  • Registrado: Sep 10, 2009
  • Mensajes: 6
  • Status: Offline

Nota Septiembre 11th, 2009, 5:51 am

Por lo tanto, este es mi código completo, menos los campos de entrada. Lo que se ve mal? Ive añade que el código PHP, y sí, estoy usando PHP, y han estado tratando de llegar a este código, yo sabía que tenía que haber algo más para llamar a la matriz a la base de datos. Gracias por esa ayuda, pero frustrado. Im sorry!! Im trabajando con Dreaweaver 9, y no me deja mi proveedor de mapa [] matriz a la base de datos. Se quiere eliminar el [] matriz? Además, no seguro de que tengo el script que siempre llama en el área correcta. La mayor parte de este código no es necesario por usted, pero me lo puso todo en, en caso de error Im en otro lugar.
Código: [ Select ]
<?php require_once('../../../Connections/oe.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
 $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;

 $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

 switch ($theType) {
  case "text":
   $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
   break;  
  case "long":
  case "int":
   $theValue = ($theValue != "") ? intval($theValue) : "NULL";
   break;
  case "double":
   $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
   break;
  case "date":
   $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
   break;
  case "defined":
   $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
   break;
 }
 return $theValue;
}
}

$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
 $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}

if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
 $insertSQL = sprintf("INSERT INTO hsa (firstName, lastName, agency, hrContact, providers, schedule) VALUES (%s, %s, %s, %s, %s, %s)",
            GetSQLValueString($_POST['firstName'], "text"),
            GetSQLValueString($_POST['lastName'], "text"),
            GetSQLValueString($_POST['agency'], "text"),
            GetSQLValueString($_POST['hrContact'], "text"),
            GetSQLValueString($_POST['providers[]'], "text"),
            GetSQLValueString($_POST['schedule'], "text"));

 mysql_select_db($database_oe, $oe);
 $Result1 = mysql_query($insertSQL, $oe) or die(mysql_error());
}

mysql_select_db($database_oe, $oe);
$query_hsa = "SELECT * FROM hsa";
$hsa = mysql_query($query_hsa, $oe) or die(mysql_error());
$row_hsa = mysql_fetch_assoc($hsa);
$totalRows_hsa = mysql_num_rows($hsa);

mysql_select_db($database_oe, $oe);
$query_providers = "SELECT * FROM providers ORDER BY provider ASC";
$providers = mysql_query($query_providers, $oe) or die(mysql_error());
$row_providers = mysql_fetch_assoc($providers);
$totalRows_providers = mysql_num_rows($providers);
?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "external link it won't let me post with">
<html xmlns="external link it won't let me post with">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>

<body>
<form id="form1" name="form1" method="POST" action="<?php echo $editFormAction; ?>">
 <label></label>
 <br />
<br />
<label>Providers
<select name="providers[]" size="4" multiple="multiple" id="providers">
<option value="Select">Select up to two options</option>
 <option value="1">BlueCross BlueShield</option>
 <option value="2">HealthPartners</option>
 <option value="3">PreferredOne</option>
 <?php $providerArr = $_POST['providers'];
foreach ($providerArr as $provider) {
  echo $provider."<br>\n";
}?>
</select>
</label>


<p>
 <label>Submit
  <input type="submit" name="submit" id="submit" value="Submit" />
  </label>
  <br />
 
<input type="hidden" name="MM_insert" value="form1" />
</form>
</body>
</html>

<?php
mysql_free_result($hsa);

mysql_free_result($providers);
?>
  1. <?php require_once('../../../Connections/oe.php'); ?>
  2. <?php
  3. if (!function_exists("GetSQLValueString")) {
  4. function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
  5. {
  6.  $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
  7.  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
  8.  switch ($theType) {
  9.   case "text":
  10.    $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
  11.    break;  
  12.   case "long":
  13.   case "int":
  14.    $theValue = ($theValue != "") ? intval($theValue) : "NULL";
  15.    break;
  16.   case "double":
  17.    $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
  18.    break;
  19.   case "date":
  20.    $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
  21.    break;
  22.   case "defined":
  23.    $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
  24.    break;
  25.  }
  26.  return $theValue;
  27. }
  28. }
  29. $editFormAction = $_SERVER['PHP_SELF'];
  30. if (isset($_SERVER['QUERY_STRING'])) {
  31.  $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
  32. }
  33. if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
  34.  $insertSQL = sprintf("INSERT INTO hsa (firstName, lastName, agency, hrContact, providers, schedule) VALUES (%s, %s, %s, %s, %s, %s)",
  35.             GetSQLValueString($_POST['firstName'], "text"),
  36.             GetSQLValueString($_POST['lastName'], "text"),
  37.             GetSQLValueString($_POST['agency'], "text"),
  38.             GetSQLValueString($_POST['hrContact'], "text"),
  39.             GetSQLValueString($_POST['providers[]'], "text"),
  40.             GetSQLValueString($_POST['schedule'], "text"));
  41.  mysql_select_db($database_oe, $oe);
  42.  $Result1 = mysql_query($insertSQL, $oe) or die(mysql_error());
  43. }
  44. mysql_select_db($database_oe, $oe);
  45. $query_hsa = "SELECT * FROM hsa";
  46. $hsa = mysql_query($query_hsa, $oe) or die(mysql_error());
  47. $row_hsa = mysql_fetch_assoc($hsa);
  48. $totalRows_hsa = mysql_num_rows($hsa);
  49. mysql_select_db($database_oe, $oe);
  50. $query_providers = "SELECT * FROM providers ORDER BY provider ASC";
  51. $providers = mysql_query($query_providers, $oe) or die(mysql_error());
  52. $row_providers = mysql_fetch_assoc($providers);
  53. $totalRows_providers = mysql_num_rows($providers);
  54. ?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "external link it won't let me post with">
  55. <html xmlns="external link it won't let me post with">
  56. <head>
  57. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  58. <title>Untitled Document</title>
  59. </head>
  60. <body>
  61. <form id="form1" name="form1" method="POST" action="<?php echo $editFormAction; ?>">
  62.  <label></label>
  63.  <br />
  64. <br />
  65. <label>Providers
  66. <select name="providers[]" size="4" multiple="multiple" id="providers">
  67. <option value="Select">Select up to two options</option>
  68.  <option value="1">BlueCross BlueShield</option>
  69.  <option value="2">HealthPartners</option>
  70.  <option value="3">PreferredOne</option>
  71.  <?php $providerArr = $_POST['providers'];
  72. foreach ($providerArr as $provider) {
  73.   echo $provider."<br>\n";
  74. }?>
  75. </select>
  76. </label>
  77. <p>
  78.  <label>Submit
  79.   <input type="submit" name="submit" id="submit" value="Submit" />
  80.   </label>
  81.   <br />
  82.  
  83. <input type="hidden" name="MM_insert" value="form1" />
  84. </form>
  85. </body>
  86. </html>
  87. <?php
  88. mysql_free_result($hsa);
  89. mysql_free_result($providers);
  90. ?>
  • 283banfil
  • Newbie
  • Newbie
  • No Avatar
  • Registrado: Sep 10, 2009
  • Mensajes: 6
  • Status: Offline

Nota Septiembre 11th, 2009, 5:59 am

Si usted me puede llevar a imaginar esto, Ill comprar una cerveza próxima vez que estés en Minnesota.
  • UPSGuy
  • Lurker ಠ_ಠ
  • Web Master
  • Avatar de Usuario
  • Registrado: Jul 25, 2005
  • Mensajes: 2735
  • Loc: Nashville, TN
  • Status: Offline

Nota Septiembre 11th, 2009, 7:03 am

¿Está tratando de almacenar las opciones seleccionadas para la base de datos o está tratando de arrancar a las opciones de seleccionar de la base de datos?

Eres un poco confusa para arriba en el código. Si usted puede aclarar el propósito, entonces podemos ayudar a enderezar lo que yo pienso. ;)
I'd love to change the world, but they won't give me the source code.
  • 283banfil
  • Newbie
  • Newbie
  • No Avatar
  • Registrado: Sep 10, 2009
  • Mensajes: 6
  • Status: Offline

Nota Septiembre 11th, 2009, 8:06 am

Tratando de pasar a la base de datos!
  • UPSGuy
  • Lurker ಠ_ಠ
  • Web Master
  • Avatar de Usuario
  • Registrado: Jul 25, 2005
  • Mensajes: 2735
  • Loc: Nashville, TN
  • Status: Offline

Nota Septiembre 11th, 2009, 10:11 am

Doke Okie. Es necesario separar el código a continuación. Su flujo debe ser una forma que se somete a un archivo PHP (la acción forma), que tiene la VARS SOLICITUD, construye una consulta de inserción, y luego se inserta en una tabla. Pruebe algo como esto o esto (esta última muestra serializar arreglos en caso de que quiera ir por ese camino).
I'd love to change the world, but they won't give me the source code.
  • 283banfil
  • Newbie
  • Newbie
  • No Avatar
  • Registrado: Sep 10, 2009
  • Mensajes: 6
  • Status: Offline

Nota Septiembre 11th, 2009, 10:29 am

Eso se ve perfecto. Gracias un montón!!
  • UPSGuy
  • Lurker ಠ_ಠ
  • Web Master
  • Avatar de Usuario
  • Registrado: Jul 25, 2005
  • Mensajes: 2735
  • Loc: Nashville, TN
  • Status: Offline

Nota Septiembre 14th, 2009, 8:09 am

Si sigue teniendo problemas con esto, por favor, reanudar la conversación aquí en lugar de comenzar un hilo duplicado. Por favor enviar su código actualizado y nos dan una nueva explicación de la cuestión y así echar un vistazo. Gracias.
I'd love to change the world, but they won't give me the source code.

Publicar Información

  • Total de mensajes en este tema: 11 mensajes
  • Usuarios navegando por este Foro: No hay usuarios registrados visitando el Foro y 143 invitados
  • No puede abrir nuevos temas en este Foro
  • No puede responder a temas en este Foro
  • No puede editar sus mensajes en este Foro
  • No puede borrar sus mensajes en este Foro
  • No puede enviar adjuntos en este Foro
 
 

© 2011 Unmelted, LLC. Ozzu® es una marca registrada de Unmelted, LLC