Ver Mensaje Individual
  #5 (permalink)  
Antiguo 31/08/2010, 01:55
Avatar de Jask
Jask
 
Fecha de Ingreso: abril-2006
Ubicación: Madrid
Mensajes: 773
Antigüedad: 18 años, 1 mes
Puntos: 15
Respuesta: Insertar campos en la BD (no es tan fácil como parece XD)

Mira de todas formas te dejo el código entero para que lo veas bien, aun así probaré con lo que me dijiste y te comento :)

Código PHP:
Ver original
  1. <h3 class='tablaNew'><u>Crear Lista</u></h3>
  2.         <?php
  3.         if(!isset($_REQUEST['selectcat']) ){
  4.            
  5.            
  6.             # Primera Parte.
  7.             # Categoría donde se va a crear la lista.
  8.         ?>
  9.    
  10.         <form action='admin.php?page=wp-listas/listas_manager.php&idcat=3&selectcat=1' method='post' name='seleccionarCategoria'>
  11.             <div class="divNew">
  12.                 Selecciona la <b>categoría</b> donde quieres crear la listas.
  13.                 <select name="elegirCategoria">
  14.                     <?php
  15.                    
  16.                     $selCatname = $wpdb->get_results("SELECT lista_c_id, lista_c_name FROM wp_lista_cat WHERE lista_c_hidden=0");
  17.                     foreach ($selCatname as $selectCatPrint){
  18.                         echo "<option>".$selectCatPrint->lista_c_name."</option>";
  19.                     } // Cierra foreach
  20.                    
  21.                     $nomLista = $selectCatPrint->lista_c_name;
  22.                    
  23.                     ?>
  24.                 </select>
  25.                 <br />
  26.                 <br />
  27.                
  28.                 Escribe un pié de foto (breve) <input name="pieFoto" type="text" size="40" />
  29.                 <div class="pieFoto"> <b>Ejemplo:</b> ¿Cual es la cantate más guapa del 2010?</div>
  30.                 <br /> <br />
  31.                
  32.                 <input name="enviarNomCatSelect" type="submit" value="Segundo Paso" />
  33.                 <input name="segundoPaso" type="hidden" value="<?php echo $nomLista; ?>" />
  34.                
  35.            </div>
  36.         </form>
  37.        
  38.         <?php
  39.        
  40.        
  41.         }else{
  42.            
  43.             # Segunda Parte.
  44.             # Escoger el número de listas.
  45.  
  46.             if(!isset($_REQUEST['selectnum']) ){
  47.  
  48.             ?>
  49.            
  50.                 <form action='admin.php?page=wp-listas/listas_manager.php&idcat=3&selectcat=1&selectnum=1' method='post' name='seleccionarCategoria'>
  51.                
  52.                     <div class="divNew">
  53.                     <?php
  54.                    
  55.                         # Pasa la descripción a la siguiente categoría.
  56.                         $descripLista = $_REQUEST['pieFoto'];
  57.                    
  58.                     ?>
  59.                    
  60.                    
  61.                     <div class="crearLista">
  62.                         <h3>Has escogido la categoría: <i><?php echo $_REQUEST['segundoPaso']; ?></i> </h3>
  63.                     </div>
  64.                    
  65.                     <br />
  66.                    
  67.                     ¿Cuántas <strong>opciones</strong> quieres que tenga tu lista? <strong>(solo numérico) </strong>
  68.                     <input name="numOpcLista" type="text" size="2" maxlength="2" style="text-align:center; margin-left:5px;" />
  69.                     <!-- Se pasa por HIDDEN los valores tanto de la categoría donde va como la descripción -->
  70.                    
  71.                     <input name="pasarCat" type="hidden" value="<?php echo $_REQUEST['segundoPaso']; ?>" />
  72.                     <input name="pasarPieImg" type="hidden" value="<?php echo $descripLista; ?>" />
  73.                    
  74.                     <!-- Fin Hidden -->
  75.                    
  76.                     <br /><br />
  77.                     <input name="tercerPaso" type="submit" value="Tercer Paso" />
  78.                    
  79.                     <div class="volverAtras">
  80.                         ¿Te has confundido de categoría? <a href="javascript:history.back(1)">Vuelve Atrás</a>
  81.                     </div>
  82.                
  83.                     </div>
  84.                
  85.                 </form>
  86.            
  87.             <?php
  88.            
  89.             }else{
  90.                
  91.                 // Variables que guardan el nombre de la categoría,
  92.                 // la descripción y el número de listas que se can a crear.
  93.                 $nomCatEscogida = $_REQUEST['pasarCat'];                // Nombre de la categoría.
  94.                 $descripcionCat = $_REQUEST['pasarPieImg'];         // Descripción de la lista.
  95.                 $numListas = $_REQUEST['numOpcLista'];                  // Número de listas que se van a crear.
  96.                    
  97.                 ?>
  98.                
  99.                 <?php
  100.                
  101.                 if(!isset($_REQUEST['crearlistas']) ){
  102.                
  103.                 ?>  
  104.                
  105.                 <div class="divNew">
  106.  
  107.                     <div class  ="resumen">
  108.                        
  109.                         <h3><u>Resumen</u></h3>
  110.                         <strong>Categoría escogida:</strong> <?php echo $nomCatEscogida; ?> <br />
  111.                         <strong>Descripción de la Lista:</strong> <?php echo $descripcionCat; ?> <br />
  112.                         <strong>Número de opciones para la lista:</strong> <?php echo $numListas; ?>
  113.                        
  114.                     </div>
  115.                    
  116.                      
  117.                 <form action="admin.php?page=wp-listas/listas_manager.php&idcat=3&selectcat=1&selectnum=1&crearlistas=true" method="post" name="subirLista">
  118.                
  119.                     <input name="pasarCatFinal" type="hidden" value="<?php echo $nomCatEscogida; ?>" />
  120.                     <input name="pasarDescripFinal" type="hidden" value="<?php echo $descripcionCat; ?>" />
  121.                
  122.                     <?php
  123.                     /*echo $_REQUEST['segundoPaso'];
  124.                     echo "<h2>Numero de listas: ".$numListas."</h2>";*/
  125.  
  126.                    
  127.                     $cajaListas = 1;
  128.                     while($cajaListas <= $_REQUEST['numOpcLista']){
  129.                         ?>
  130.                        
  131.                         <div class="whileLista">
  132.                    
  133.                         <table width="450" border="0">
  134.                           <tr>
  135.                             <td width="15%" rowspan="2" class="colorfondonumero"><?php echo $cajaListas; ?></td>
  136.                             <td width="22%" align="right">Nombre</td>
  137.                             <td width="4%">&nbsp;</td>
  138.                             <td width="59%"><input name="listaName<?php echo $cajaListas; ?>" type="text" size="30" /></td>
  139.                           </tr>
  140.                           <tr>
  141.                             <td align="right">Imagen</td>
  142.                             <td>&nbsp;</td>
  143.                             <td><input name="listaImg<?php echo $cajaListas; ?>" type="text" size="30" /></td>
  144.                           </tr>
  145.                         </table>
  146.                    
  147.                     </div>
  148.                        
  149.                         <?php
  150.                         $cajaListas +=1;
  151.                     } // Cierra el while
  152.                    
  153.                     ?>
  154.                     <input name="crearListasFin" type="submit" value="Crear Listas"/>
  155.                    
  156.                 </form>
  157.                
  158.                     <?php
  159.                     // Este ELSE pertece al isset de crearlista
  160.                     }else{
  161.                        
  162.                         // Insert para subir las Listas creadas.
  163.                        
  164.                         ###############################
  165.                        
  166.                         $pasarCatFinal = $_REQUEST['pasarCatFinal'];
  167.                         $pasarDescripFinal =  $_REQUEST['pasarDescripFinal'];
  168.                        
  169.                        
  170.                         if(isset($_REQUEST['listaName1'])){
  171.                            
  172.                             /*
  173.                            
  174.                                             SEGUIR POR AQUÍ, VER SENTENCIA PARA QUE SE SUBA BIEN.
  175.                    
  176.                             */     
  177.                                                
  178.                             $listaName1 = $_REQUEST['listaName1'];
  179.                             $listaImg1 = $_REQUEST['listaImg1'];
  180.                             $sql1 = "INSERT INTO wp_lista (lista_nombre, lista_imagen, lista_categoria, lista_nombreunico) VALUES ('$listaName1', '$listaImg1', '$pasarCatFinal', '$pasarDescripFinal' );";
  181.                             if($wpdb->query($sql1)){
  182.                                 echo "Se ha subido la primera noticia";
  183.                             }
  184.                                
  185.                         }
  186.                            
  187.                         if(isset($_REQUEST['listaName2'])){
  188.                             $listaName2 = $_REQUEST['listaName2'];
  189.                             $listaImg2 = $_REQUEST['listaImg2'];
  190.                         }
  191.                        
  192.                         if(isset($_REQUEST['listaName3'])){
  193.                             $listaName3 = $_REQUEST['listaName3'];
  194.                             $listaImg3 = $_REQUEST['listaImg3'];
  195.                         }
  196.                        
  197.                         if(isset($_REQUEST['listaName4'])){
  198.                             $listaName4 = $_REQUEST['listaName4'];
  199.                             $listaImg4 = $_REQUEST['listaImg4'];
  200.                         }
  201.                        
  202.                         if(isset($_REQUEST['listaName5'])){
  203.                             $listaName5 = $_REQUEST['listaName5'];
  204.                             $listaImg5 = $_REQUEST['listaImg5'];
  205.                         }
  206.                        
  207.                         if(isset($_REQUEST['listaName6'])){
  208.                             $listaName6 = $_REQUEST['listaName6'];
  209.                             $listaImg6 = $_REQUEST['listaImg6'];
  210.                         }
  211.                        
  212.                         if(isset($_REQUEST['listaName7'])){
  213.                             $listaName7 = $_REQUEST['listaName7'];
  214.                             $listaImg7 = $_REQUEST['listaImg7'];
  215.                         }
  216.                        
  217.                         if(isset($_REQUEST['listaName8'])){
  218.                             $listaName8 = $_REQUEST['listaName8'];
  219.                             $listaImg8 = $_REQUEST['listaImg8'];
  220.                         }
  221.                        
  222.                         if(isset($_REQUEST['listaName9'])){
  223.                             $listaName9 = $_REQUEST['listaName9'];
  224.                             $listaImg9 = $_REQUEST['listaImg9'];
  225.                         }
  226.                        
  227.                         if(isset($_REQUEST['listaName10'])){
  228.                             $listaName10 = $_REQUEST['listaName10'];
  229.                             $listaImg10 = $_REQUEST['listaImg10'];
  230.                         }
  231.                        
  232.                         ###############################
  233.    
  234.                             $sql = "INSERT INTO wp_lista (lista_nombre, lista_imagen, lista_categoria, lista_nombreunico) VALUES ('$catNewNom', '$catDescrip');";
  235.                        
  236.                         /* 
  237.                             if($wpdb->query($sql)){
  238.                                 echo "<div class='divNew alertaOk'><span class='alertaTexto alertaTextoVerde'>La categoría se ha creado correctamente.</span></div>";
  239.                             }else{
  240.                                 echo "<div class='divNew alerta'><span class='alertaTexto alertaTextoRoja'>Se ha producido un error. <a href='javascript:history.back(1)'>Volver Atrás </a></span></div>";
  241.                             }
  242.                         */
  243.                        
  244.                     }
  245.                    
  246.                     ?>
  247.                 </div>
  248.                
  249.                 <?php
  250.                
  251.             } // Cierra selectNumer
  252.            
  253.            
  254.         }

Un saludo y muchas gracias !


EDIT

Muchísimas gracias tío, sos un crack :) !! La verdad que le estuve dando vueltas como me lo pusiste pero no se me había ocurrido un par de cosas, la verdad que me vino de lujo :)

En serio, muchísimas gracias jefe !!
__________________
Os iusti meditabitur sapientiam
Si te he ayudado, por qué no un poquito de Karma :) ?

Última edición por Jask; 31/08/2010 a las 02:01 Razón: Solucionado