Foros del Web » Programando para Internet » PHP »

[SOLUCIONADO] como hago un array para selecciones multiples

Estas en el tema de como hago un array para selecciones multiples en el foro de PHP en Foros del Web. hola a todos soy nuevo aqui en este foro y tambien en programacion php... espero su ayuda... tengo un problema... resulta que estoy haciendo una ...
  #1 (permalink)  
Antiguo 02/05/2014, 19:16
 
Fecha de Ingreso: mayo-2014
Ubicación: valparaiso, chile
Mensajes: 34
Antigüedad: 9 años, 11 meses
Puntos: 0
Pregunta como hago un array para selecciones multiples

hola a todos soy nuevo aqui en este foro y tambien en programacion php...
espero su ayuda... tengo un problema...
resulta que estoy haciendo una web de peliculas en las que las categorias las agrego desde la administracion al igual que las peliculas....
mi problema es que hay algunas peliculas que quiero agregar a mas de una categoria a la vez, lo estoy tratando de hacer con selecciones multiples,
me dijieron que para hacerlo de esta forma nesecito agregarle al nombre
esto [], pero resulta que cuando lo hago, abro la web en el navegador y al agregar las peliculas a las categorias doy enviar y me sale el error siguiente: ---Column 'intCategoria' cannot be null--- ademas no se si aparte de agregar [] tambien tengo que escribir algun codigo adicional como hacer un array o algo asi...
bueno aqui esta el codigo...
Código PHP:
<select name="intCategoria[]" size="1" multiple="MULTIPLE" id="intCategoria[]">
              <?php
do {  
?>
              <option value="<?php echo $row_consulta_categorias['idCategoria']?>"><?php echo $row_consulta_categorias['strDescripcion']?></option>
              <?php
} while ($row_consulta_categorias mysql_fetch_assoc($consulta_categorias));
  
$rows mysql_num_rows($consulta_categorias);
  if(
$rows 0) {
      
mysql_data_seek($consulta_categorias0);
      
$row_consulta_categorias mysql_fetch_assoc($consulta_categorias);
  }
?>
          </select>
por favor pido ayuda
p.d. uso dreamweaver cs6
  #2 (permalink)  
Antiguo 03/05/2014, 00:20
Avatar de caricatos
Moderador
 
Fecha de Ingreso: abril-2002
Ubicación: Torremolinos (Málaga)
Mensajes: 19.607
Antigüedad: 22 años
Puntos: 1284
Respuesta: como hago un array para selecciones multiples

Hola:

Cuando agregas un juego de corchetes a los campos, estás indicando que envías un array, así que luego debes procesar ese campo como un array, por ejemplo convirtiéndolo en una cadena con un implode... y comprobar antes su existencia por si no se selecciona ninguna opción...

Por cierto, la funcionalidad de un select múltiple es la misma que una serie de checkboxes con el mismo nombre (y también con su juego de corchetes).

Saludos
__________________
Por favor:
No hagan preguntas de temas de foros en mensajes privados... no las respondo
  #3 (permalink)  
Antiguo 03/05/2014, 17:46
 
Fecha de Ingreso: mayo-2014
Ubicación: valparaiso, chile
Mensajes: 34
Antigüedad: 9 años, 11 meses
Puntos: 0
Respuesta: como hago un array para selecciones multiples

muchas gracias caricatos ahora entiendo por que no me resultaba, pero ademas quiero saber si me puedes ayudar a como hacer ese codigo en base al codigo que puse arriba en la pregunta
por favor
  #4 (permalink)  
Antiguo 04/05/2014, 00:13
Avatar de caricatos
Moderador
 
Fecha de Ingreso: abril-2002
Ubicación: Torremolinos (Málaga)
Mensajes: 19.607
Antigüedad: 22 años
Puntos: 1284
Respuesta: como hago un array para selecciones multiples

Hola:

Por lo que veo, las líneas serían:

$cates = (isset($_POST["intCategoria"])) ? "categoria='".implode(",", $_POST["intCategoria"])."'," : "";

$sql "update $tabla set $cates otrosCampos='$otrosValores' ...";

Saludos
__________________
Por favor:
No hagan preguntas de temas de foros en mensajes privados... no las respondo
  #5 (permalink)  
Antiguo 04/05/2014, 18:27
 
Fecha de Ingreso: mayo-2014
Ubicación: valparaiso, chile
Mensajes: 34
Antigüedad: 9 años, 11 meses
Puntos: 0
Respuesta: como hago un array para selecciones multiples

esto me arroja error de sintaxis:
Código PHP:
Ver original
  1. $sql "update $tabla set $cates otrosCampos='$otrosValores' ...";
creo que es porque tengo que cambiar algun valor de lo que tu me diste pero no se cual es

no se si esto ayude pero aqui esta el codigo completo:
Código PHP:
Ver original
  1. <?php require_once('../Connections/conexion_pelislatino.php'); ?>
  2. <?php
  3. if (!function_exists("GetSQLValueString")) {
  4. function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
  5. {
  6.   if (PHP_VERSION < 6) {
  7.     $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
  8.   }
  9.  
  10.   $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
  11.  
  12.   switch ($theType) {
  13.     case "text":
  14.       $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
  15.       break;    
  16.     case "long":
  17.     case "int":
  18.       $theValue = ($theValue != "") ? intval($theValue) : "NULL";
  19.       break;
  20.     case "double":
  21.       $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
  22.       break;
  23.     case "date":
  24.       $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
  25.       break;
  26.     case "defined":
  27.       $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
  28.       break;
  29.   }
  30.   return $theValue;
  31. }
  32. }
  33.  
  34. $editFormAction = $_SERVER['PHP_SELF'];
  35. if (isset($_SERVER['QUERY_STRING'])) {
  36.   $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
  37. }
  38.  
  39.  
  40. if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
  41.   $insertSQL = sprintf("INSERT INTO tblpelicula (strNombre, intCategoria, strImagen, strSinopsis, strInfo, strLinks) VALUES (%s, %s, %s, %s, %s, %s)",
  42.                        GetSQLValueString($_POST['strNombre'], "text"),
  43.                        GetSQLValueString($_POST['intCategoria'], "int"),
  44.                        GetSQLValueString($_POST['strImagen'], "text"),
  45.                        GetSQLValueString($_POST['strSinopsis'], "text"),
  46.                        GetSQLValueString($_POST['strInfo'], "text"),
  47.                        GetSQLValueString($_POST['strLinks'], "text"));
  48.  
  49.   mysql_select_db($database_conexion_pelislatino, $conexion_pelislatino);
  50.   $Result1 = mysql_query($insertSQL, $conexion_pelislatino) or die(mysql_error());
  51.  
  52.   $insertGoTo = "peliculas_lista.php";
  53.   if (isset($_SERVER['QUERY_STRING'])) {
  54.     $insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
  55.     $insertGoTo .= $_SERVER['QUERY_STRING'];
  56.   }
  57.   header(sprintf("Location: %s", $insertGoTo));
  58. }
  59.  
  60. mysql_select_db($database_conexion_pelislatino, $conexion_pelislatino);
  61. $query_consulta_categorias = "SELECT * FROM tblcategoria ORDER BY tblcategoria.strDescripcion ASC";
  62. $consulta_categorias = mysql_query($query_consulta_categorias, $conexion_pelislatino) or die(mysql_error());
  63. $row_consulta_categorias = mysql_fetch_assoc($consulta_categorias);
  64. $totalRows_consulta_categorias = mysql_num_rows($consulta_categorias);
  65. ?>
  66. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  67. <html xmlns="http://www.w3.org/1999/xhtml"><!-- InstanceBegin template="/Templates/baseadmin.dwt.php" codeOutsideHTMLIsLocked="false" -->
  68. <head>
  69. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  70. <!-- InstanceBeginEditable name="doctitle" -->
  71. <title>admin</title>
  72. <!-- InstanceEndEditable -->
  73. <!-- InstanceBeginEditable name="head" -->
  74. <script src="../SpryAssets/SpryValidationTextField.js" type="text/javascript"></script>
  75. <link href="../SpryAssets/SpryValidationTextField.css" rel="stylesheet" type="text/css" />
  76. <!-- InstanceEndEditable -->
  77. <link href="../estilo/baseadmin.css" rel="stylesheet" type="text/css" />
  78. </head>
  79.  
  80. <body>
  81.  
  82. <div class="container">
  83.   <div class="header"><!-- end .header -->
  84.     <p><img src="http://www.forosdelweb.com/f18/images/diseño/foto%20principal%20web.JPG" width="943" height="201" alt="logo" /></p>
  85.   </div>
  86.   <div class="sidebar1">
  87.   <?php include("../includes/cabeceraadmin.php");
  88.   ?>
  89.     <ul class="nav">
  90.       <li></li></ul>
  91.     <!-- end .sidebar1 --></div>
  92.   <div class="content">
  93.     <h1><!-- InstanceBeginEditable name="encabezado" -->añadir pelicula<!-- InstanceEndEditable --></h1>
  94.     <!-- InstanceBeginEditable name="contenido" -->
  95.    
  96.     <script>
  97. function subirimagen()
  98. {
  99.         self.name = 'opener';
  100.         remote = open('gestionimagen.php', 'remote',
  101.         'width=400,heighht=150,location=no,scrollbars=yes,menubars=no,toolbars=no,resizable=yes,fullscreen=no, status=yes');
  102.         remote.focus();
  103.         }
  104.    
  105.     </script>
  106.    
  107.     <p>&nbsp;</p>
  108.     <p>&nbsp;</p>
  109.     <form action="<?php echo $editFormAction; ?>" method="POST" name="form1" id="form1">
  110.       <table align="center">
  111.         <tr valign="baseline">
  112.           <td width="86" align="right" nowrap="nowrap">Nombre:</td>
  113.           <td width="271"><span id="sprytextfield1">
  114.             <input type="text" name="strNombre" value="" size="32" />
  115.           <span class="textfieldRequiredMsg">Se necesita un valor.</span></span></td>
  116.         </tr>
  117.         <tr valign="baseline">
  118.           <td nowrap="nowrap" align="right">Imagen:</td>
  119.           <td><label for="strImagen"></label>
  120.             <span id="sprytextfield2">
  121.             <input type="text" name="strImagen" id="strImagen" />
  122.           <span class="textfieldRequiredMsg">Se necesita un valor.</span></span>            <input type="button" name="button" id="button" value="subir imagen" onclick="javascript:subirimagen();"/></td>
  123.         </tr>
  124.         <tr valign="baseline">
  125.           <td nowrap="nowrap" align="right">Categoria:</td>
  126.           <td><label for="intCategoria[]"></label>
  127.             <select name="intCategoria[]" size="1" multiple="MULTIPLE" id="intCategoria[]">
  128.             <?php $cates = (isset($_POST["intCategoria"])) ? "categoria='".implode(",", $_POST["intCategoria"])."'," : "";
  129.  
  130. $sql "update $tabla set $cates otrosCampos='$otrosValores' ...";
  131. ?>
  132.               <?php
  133. do {  
  134. ?>
  135.               <option value="<?php echo $row_consulta_categorias['idCategoria']?>"><?php echo $row_consulta_categorias['strDescripcion']?></option>
  136.               <?php
  137. } while ($row_consulta_categorias = mysql_fetch_assoc($consulta_categorias));
  138.   $rows = mysql_num_rows($consulta_categorias);
  139.   if($rows > 0) {
  140.       mysql_data_seek($consulta_categorias, 0);
  141.       $row_consulta_categorias = mysql_fetch_assoc($consulta_categorias);
  142.   }
  143. ?>
  144.           </select></td>
  145.         </tr>
  146.         <tr valign="baseline">
  147.           <td nowrap="nowrap" align="right">Sinopsis:</td>
  148.           <td><label for="strInfo"></label>
  149.           <input type="text" name="strSinopsis" id="strSinopsis" /></td>
  150.         </tr>
  151.         <tr valign="baseline">
  152.           <td nowrap="nowrap" align="right">Info:</td>
  153.           <td><label for="strInfo"></label>
  154.             <label for="strInfo"></label>
  155.           <textarea name="strInfo" id="strInfo" cols="45" rows="5"></textarea></td>
  156.         </tr>
  157.         <tr valign="baseline">
  158.           <td nowrap="nowrap" align="right">Links:</td>
  159.           <td><label for="strLinks"></label>
  160.           <input type="text" name="strLinks" id="strLinks" /></td>
  161.         </tr>
  162.         <tr valign="baseline">
  163.           <td nowrap="nowrap" align="right">&nbsp;</td>
  164.           <td><input type="submit" value="Insertar pelicula" /></td>
  165.         </tr>
  166.       </table>
  167.       <input type="hidden" name="MM_insert" value="form1" />
  168.       <input type="hidden" name="MM_insert" value="form1" />
  169.     </form>
  170.     <p>&nbsp;</p>
  171.     <script type="text/javascript">
  172. var sprytextfield1 = new Spry.Widget.ValidationTextField("sprytextfield1");
  173. var sprytextfield2 = new Spry.Widget.ValidationTextField("sprytextfield2");
  174.     </script>
  175.     <!-- InstanceEndEditable --><!-- end .content --></div>
  176.   <div class="footer">
  177.     <p>administracion de pelis latino</p>
  178.     <!-- end .footer --></div>
  179.   <!-- end .container --></div>
  180. </body>
  181. <!-- InstanceEnd --></html>
  182. <?php
  183. mysql_free_result($consulta_categorias);
  184. ?>
  #6 (permalink)  
Antiguo 06/05/2014, 19:40
 
Fecha de Ingreso: mayo-2014
Ubicación: valparaiso, chile
Mensajes: 34
Antigüedad: 9 años, 11 meses
Puntos: 0
Pregunta Respuesta: como hago un array para selecciones multiples

Cita:
Iniciado por caricatos Ver Mensaje
Hola:

Cuando agregas un juego de corchetes a los campos, estás indicando que envías un array, así que luego debes procesar ese campo como un array, por ejemplo convirtiéndolo en una cadena con un implode... y comprobar antes su existencia por si no se selecciona ninguna opción...

Por cierto, la funcionalidad de un select múltiple es la misma que una serie de checkboxes con el mismo nombre (y también con su juego de corchetes).

Saludos
Cita:
Iniciado por caricatos Ver Mensaje
Hola:

Por lo que veo, las líneas serían:

$cates = (isset($_POST["intCategoria"])) ? "categoria='".implode(",", $_POST["intCategoria"])."'," : "";

$sql "update $tabla set $cates otrosCampos='$otrosValores' ...";

Saludos

esto me arroja error de sintaxis:
Código PHP:
Ver original
  1. $sql "update $tabla set $cates otrosCampos='$otrosValores' ...";

creo que es porque tengo que cambiar algun valor de lo que tu me diste pero no se cual es

no se si esto ayude pero aqui esta el codigo completo:

Código PHP:
Ver original
  1. <?php require_once('../Connections/conexion_pelislatino.php'); ?>
  2. <?php
  3. if (!function_exists("GetSQLValueString")) {
  4. function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
  5. {
  6.   if (PHP_VERSION < 6) {
  7.     $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
  8.   }
  9.  
  10.   $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
  11.  
  12.   switch ($theType) {
  13.     case "text":
  14.       $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
  15.       break;    
  16.     case "long":
  17.     case "int":
  18.       $theValue = ($theValue != "") ? intval($theValue) : "NULL";
  19.       break;
  20.     case "double":
  21.       $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
  22.       break;
  23.     case "date":
  24.       $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
  25.       break;
  26.     case "defined":
  27.       $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
  28.       break;
  29.   }
  30.   return $theValue;
  31. }
  32. }
  33.  
  34. $editFormAction = $_SERVER['PHP_SELF'];
  35. if (isset($_SERVER['QUERY_STRING'])) {
  36.   $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
  37. }
  38.  
  39.  
  40. if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
  41.   $insertSQL = sprintf("INSERT INTO tblpelicula (strNombre, intCategoria, strImagen, strSinopsis, strInfo, strLinks) VALUES (%s, %s, %s, %s, %s, %s)",
  42.                        GetSQLValueString($_POST['strNombre'], "text"),
  43.                        GetSQLValueString($_POST['intCategoria'], "int"),
  44.                        GetSQLValueString($_POST['strImagen'], "text"),
  45.                        GetSQLValueString($_POST['strSinopsis'], "text"),
  46.                        GetSQLValueString($_POST['strInfo'], "text"),
  47.                        GetSQLValueString($_POST['strLinks'], "text"));
  48.  
  49.   mysql_select_db($database_conexion_pelislatino, $conexion_pelislatino);
  50.   $Result1 = mysql_query($insertSQL, $conexion_pelislatino) or die(mysql_error());
  51.  
  52.   $insertGoTo = "peliculas_lista.php";
  53.   if (isset($_SERVER['QUERY_STRING'])) {
  54.     $insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
  55.     $insertGoTo .= $_SERVER['QUERY_STRING'];
  56.   }
  57.   header(sprintf("Location: %s", $insertGoTo));
  58. }
  59.  
  60. mysql_select_db($database_conexion_pelislatino, $conexion_pelislatino);
  61. $query_consulta_categorias = "SELECT * FROM tblcategoria ORDER BY tblcategoria.strDescripcion ASC";
  62. $consulta_categorias = mysql_query($query_consulta_categorias, $conexion_pelislatino) or die(mysql_error());
  63. $row_consulta_categorias = mysql_fetch_assoc($consulta_categorias);
  64. $totalRows_consulta_categorias = mysql_num_rows($consulta_categorias);
  65. ?>
  66. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  67. <html xmlns="http://www.w3.org/1999/xhtml"><!-- InstanceBegin template="/Templates/baseadmin.dwt.php" codeOutsideHTMLIsLocked="false" -->
  68. <head>
  69. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  70. <!-- InstanceBeginEditable name="doctitle" -->
  71. <title>admin</title>
  72. <!-- InstanceEndEditable -->
  73. <!-- InstanceBeginEditable name="head" -->
  74. <script src="../SpryAssets/SpryValidationTextField.js" type="text/javascript"></script>
  75. <link href="../SpryAssets/SpryValidationTextField.css" rel="stylesheet" type="text/css" />
  76. <!-- InstanceEndEditable -->
  77. <link href="../estilo/baseadmin.css" rel="stylesheet" type="text/css" />
  78. </head>
  79.  
  80. <body>
  81.  
  82. <div class="container">
  83.   <div class="header"><!-- end .header -->
  84.     <p><img src="http://www.forosdelweb.com/f18/images/diseño/foto%20principal%20web.JPG" width="943" height="201" alt="logo" /></p>
  85.   </div>
  86.   <div class="sidebar1">
  87.   <?php include("../includes/cabeceraadmin.php");
  88.   ?>
  89.     <ul class="nav">
  90.       <li></li></ul>
  91.     <!-- end .sidebar1 --></div>
  92.   <div class="content">
  93.     <h1><!-- InstanceBeginEditable name="encabezado" -->añadir pelicula<!-- InstanceEndEditable --></h1>
  94.     <!-- InstanceBeginEditable name="contenido" -->
  95.    
  96.     <script>
  97. function subirimagen()
  98. {
  99.         self.name = 'opener';
  100.         remote = open('gestionimagen.php', 'remote',
  101.         'width=400,heighht=150,location=no,scrollbars=yes,menubars=no,toolbars=no,resizable=yes,fullscreen=no, status=yes');
  102.         remote.focus();
  103.         }
  104.    
  105.     </script>
  106.    
  107.     <p>&nbsp;</p>
  108.     <p>&nbsp;</p>
  109.     <form action="<?php echo $editFormAction; ?>" method="POST" name="form1" id="form1">
  110.       <table align="center">
  111.         <tr valign="baseline">
  112.           <td width="86" align="right" nowrap="nowrap">Nombre:</td>
  113.           <td width="271"><span id="sprytextfield1">
  114.             <input type="text" name="strNombre" value="" size="32" />
  115.           <span class="textfieldRequiredMsg">Se necesita un valor.</span></span></td>
  116.         </tr>
  117.         <tr valign="baseline">
  118.           <td nowrap="nowrap" align="right">Imagen:</td>
  119.           <td><label for="strImagen"></label>
  120.             <span id="sprytextfield2">
  121.             <input type="text" name="strImagen" id="strImagen" />
  122.           <span class="textfieldRequiredMsg">Se necesita un valor.</span></span>            <input type="button" name="button" id="button" value="subir imagen" onclick="javascript:subirimagen();"/></td>
  123.         </tr>
  124.         <tr valign="baseline">
  125.           <td nowrap="nowrap" align="right">Categoria:</td>
  126.           <td><label for="intCategoria[]"></label>
  127.             <select name="intCategoria[]" size="1" multiple="MULTIPLE" id="intCategoria[]">
  128.             <?php $cates = (isset($_POST["intCategoria"])) ? "categoria='".implode(",", $_POST["intCategoria"])."'," : "";
  129.  
  130. $sql "update $tabla set $cates otrosCampos='$otrosValores' ...";
  131. ?>
  132.               <?php
  133. do {  
  134. ?>
  135.               <option value="<?php echo $row_consulta_categorias['idCategoria']?>"><?php echo $row_consulta_categorias['strDescripcion']?></option>
  136.               <?php
  137. } while ($row_consulta_categorias = mysql_fetch_assoc($consulta_categorias));
  138.   $rows = mysql_num_rows($consulta_categorias);
  139.   if($rows > 0) {
  140.       mysql_data_seek($consulta_categorias, 0);
  141.       $row_consulta_categorias = mysql_fetch_assoc($consulta_categorias);
  142.   }
  143. ?>
  144.           </select></td>
  145.         </tr>
  146.         <tr valign="baseline">
  147.           <td nowrap="nowrap" align="right">Sinopsis:</td>
  148.           <td><label for="strInfo"></label>
  149.           <input type="text" name="strSinopsis" id="strSinopsis" /></td>
  150.         </tr>
  151.         <tr valign="baseline">
  152.           <td nowrap="nowrap" align="right">Info:</td>
  153.           <td><label for="strInfo"></label>
  154.             <label for="strInfo"></label>
  155.           <textarea name="strInfo" id="strInfo" cols="45" rows="5"></textarea></td>
  156.         </tr>
  157.         <tr valign="baseline">
  158.           <td nowrap="nowrap" align="right">Links:</td>
  159.           <td><label for="strLinks"></label>
  160.           <input type="text" name="strLinks" id="strLinks" /></td>
  161.         </tr>
  162.         <tr valign="baseline">
  163.           <td nowrap="nowrap" align="right">&nbsp;</td>
  164.           <td><input type="submit" value="Insertar pelicula" /></td>
  165.         </tr>
  166.       </table>
  167.       <input type="hidden" name="MM_insert" value="form1" />
  168.       <input type="hidden" name="MM_insert" value="form1" />
  169.     </form>
  170.     <p>&nbsp;</p>
  171.     <script type="text/javascript">
  172. var sprytextfield1 = new Spry.Widget.ValidationTextField("sprytextfield1");
  173. var sprytextfield2 = new Spry.Widget.ValidationTextField("sprytextfield2");
  174.     </script>
  175.     <!-- InstanceEndEditable --><!-- end .content --></div>
  176.   <div class="footer">
  177.     <p>administracion de pelis latino</p>
  178.     <!-- end .footer --></div>
  179.   <!-- end .container --></div>
  180. </body>
  181. <!-- InstanceEnd --></html>
  182. <?php
  183. mysql_free_result($consulta_categorias);
  184. ?>

ayuda plis
  #7 (permalink)  
Antiguo 06/05/2014, 20:05
Avatar de Italico76  
Fecha de Ingreso: abril-2007
Mensajes: 3.303
Antigüedad: 17 años
Puntos: 292
Respuesta: como hago un array para selecciones multiples

Código PHP:
Ver original
  1. $sql "update $tabla set $cates otrosCampos='$otrosValores' ...";

mmm

Te dieron un hueso pero deberias poder chequear la sintaxis y depurar una linea de codigo:


- Donde esta el igual (=) para asignar ese string a $sql ? $sql = ....

- No te parece raro eso de los puntos suspensivos al final ? es es como decir "sigue ahi lo que quieras"


Arregla lo mas OBVIO y luego haz un var_dump($sql) para ir viendo si lo que te genera tiene sentido para el motor de MySQL
__________________
Salu2!
  #8 (permalink)  
Antiguo 08/05/2014, 19:34
 
Fecha de Ingreso: mayo-2014
Ubicación: valparaiso, chile
Mensajes: 34
Antigüedad: 9 años, 11 meses
Puntos: 0
Pregunta Respuesta: como hago un array para selecciones multiples

Cita:
Iniciado por Italico76 Ver Mensaje
Código PHP:
Ver original
  1. $sql "update $tabla set $cates otrosCampos='$otrosValores' ...";

mmm

Te dieron un hueso pero deberias poder chequear la sintaxis y depurar una linea de codigo:


- Donde esta el igual (=) para asignar ese string a $sql ? $sql = ....

- No te parece raro eso de los puntos suspensivos al final ? es es como decir "sigue ahi lo que quieras"


Arregla lo mas OBVIO y luego haz un var_dump($sql) para ir viendo si lo que te genera tiene sentido para el motor de MySQL
para serte sincero yo hice esta web con un totorial acerca de una tienda online
y lo modifique como una web de peliculas, no se casi nada de php pero lo unico que me falta es esto que estoy planteando y paginar (eso de paginar lo tengo casi listo)... volviendo al tema... --------dreamweaver ya no me arroja error de sintaxis pero aun sigo sin agregar mas de un a categoria a la vez y no supe como hacer el var_dump($sql)... ademas doy un dato mas el campo intCategoria es un integer y las categorias que tengo estan agregadas dinamicamente
Help me please
aqui esta como quedo el nuevo codigo:
Código PHP:
Ver original
  1. <select name="intCategoria[]" size="1" multiple="MULTIPLE" id="intCategoria[]">
  2.             <?php $cates = (isset($_POST["intCategoria"])) ? "categoria='".implode(",", $_POST["intCategoria"])."'," : "";
  3.  
  4. $sql = "update $tabla set $cates otrosCampos='$otrosValores'";?>
  5.             <?php
  6. do {  
  7. ?>
  8.               <option value="<?php echo $row_consulta_categorias['idCategoria']?>"><?php echo $row_consulta_categorias['strDescripcion']?></option>
  9.              
  10.               <?php
  11. } while ($row_consulta_categorias = mysql_fetch_assoc($consulta_categorias));
  12.   $rows = mysql_num_rows($consulta_categorias);
  13.   if($rows > 0) {
  14.       mysql_data_seek($consulta_categorias, 0);
  15.       $row_consulta_categorias = mysql_fetch_assoc($consulta_categorias);
  16.   }
  17. ?>
  18.           </select>

Última edición por relampago846; 08/05/2014 a las 19:39 Razón: me falto agregar como quedo el nuevo codigo

Etiquetas: dreamweavercs6, multiples, selecciones
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 13:33.