elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.

 

 


Tema destacado: Estamos en la red social de Mastodon


  Mostrar Mensajes
Páginas: 1 ... 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 ... 138
291  Programación / PHP / Re: Ordenar registros en: 13 Julio 2009, 20:05 pm
Ya pude xDDDD

Se los dejo por si lo llegan a usar:

Código
  1. <?php
  2. //--------------------------------------------------------------+
  3. // Include module settings |
  4. //--------------------------------------------------------------+
  5. require_once("settings.php");
  6. //--------------------------------------------------------------+
  7. // Case Up |
  8. //--------------------------------------------------------------+
  9. if($var['order']=="up"){
  10. //--------------------------------------------------------------+
  11. // First get the pre Number ID slot |
  12. //--------------------------------------------------------------+
  13. $DBQuery->attrib['query'] = "SELECT slot FROM `banner` WHERE `id_banner` ='".$var['idpreslot']."'";
  14. //echo $DBQuery->attrib['query'];
  15. $getPreSlot = $DBQuery->RunQuery();
  16.  
  17. //--------------------------------------------------------------+
  18. // Update the pre item with last number ID slot |
  19. //--------------------------------------------------------------+
  20. $DBQuery->attrib['query'] = "UPDATE `banner` SET `slot` = '".$var['slot']."' WHERE `id_banner` ='".$var['idpreslot']."'";
  21. //echo $DBQuery->attrib['query'];
  22. $upPreSlot=$DBQuery->RunQuery();
  23.  
  24. //--------------------------------------------------------------+
  25. // As finaly, update the item with pre number ID slot |
  26. //--------------------------------------------------------------+
  27. $DBQuery->attrib['query'] = "UPDATE `banner` SET `slot` = '".$getPreSlot[0]['slot']."' WHERE `id_banner` ='".$var['id_banner']."'";
  28. //echo $DBQuery->attrib['query'];
  29. $upSlot=$DBQuery->RunQuery();
  30. }
  31. //--------------------------------------------------------------+
  32. // Case Down |
  33. //--------------------------------------------------------------+
  34. if($var['order']=="down"){
  35. //--------------------------------------------------------------+
  36. // First get the next Number ID slot and ID_banner |
  37. //--------------------------------------------------------------+
  38. $DBQuery->attrib['query'] = "SELECT id_banner, slot FROM `banner` WHERE `slot` ='".$var['idnextslot']."'";
  39. //echo $DBQuery->attrib['query']."<br>";
  40. $getNextSlot = $DBQuery->RunQuery();
  41.  
  42. //--------------------------------------------------------------+
  43. // Update the original entry with the new id_slot |
  44. //--------------------------------------------------------------+
  45. $DBQuery->attrib['query'] = "UPDATE `banner` SET `slot` = '".$var['idnextslot']."' WHERE `id_banner` ='".$var['id_banner']."'";
  46. //echo $DBQuery->attrib['query']."<br>";
  47. $downSlot=$DBQuery->RunQuery();
  48.  
  49. //--------------------------------------------------------------+
  50. // Update the entry target with the old slot |
  51. //--------------------------------------------------------------+
  52. $DBQuery->attrib['query'] = "UPDATE `banner` SET `slot` = '".$var['slot']."' WHERE `id_banner` ='".$getNextSlot[0]['id_banner']."'";
  53. //echo $DBQuery->attrib['query']."<br>";
  54. $downSlot=$DBQuery->RunQuery();
  55.  
  56. }
  57.  
  58. Location("index.php?action=".$lo_mod_name.".banshort");
  59. ?>
  60.  

Igual y no le entienden porque es parte de un FM que estoy haciendo pero bueno, cualquier consejo es bienvenido  :)
292  Programación / PHP / Ordenar registros en: 13 Julio 2009, 19:41 pm
Hola PHPecheros,

Tengo una duda, que más que duda siento es error de lógica:

Tengo una tabla "banner":

Código:
mysql> describe banner;
+---------------+------------------+------+-----+---------+----------------+
| Field         | Type             | Null | Key | Default | Extra          |
+---------------+------------------+------+-----+---------+----------------+
| id_banner     | int(10) unsigned | NO   | PRI | NULL    | auto_increment |
| nombre        | varchar(45)      | YES  |     | NULL    |                |
| archivo       | varchar(200)     | YES  |     | NULL    |                |
| thumbnail     | varchar(200)     | YES  |     | NULL    |                |
| ventana_nueva | tinyint(1)       | YES  |     | NULL    |                |
| url           | varchar(255)     | YES  |     | NULL    |                |
| activo        | tinyint(1)       | YES  |     | 1       |                |
| borrado       | tinyint(1)       | YES  |     | 0       |                |
| altura        | int(11)          | NO   |     |         |                |
| anchura       | int(11)          | NO   |     |         |                |
| defront       | tinyint(1)       | NO   |     |         |                |
| slot          | int(10) unsigned | NO   | UNI |         |                |
+---------------+------------------+------+-----+---------+----------------+
12 rows in set (0.00 sec)

En donde verán un campo llamado slot(int) que sirve para almacenar de 1 a N (sin que se repitan), esto se hace para ordenar de forma visual mis registros. La duda radica es cómo hacer un manager para controlar el orden.

Lo que hice fue hacer una lista con un par de flechas por cada registro, si es el slot==1 no pongo la flecha hacia "arriba", y de igual forma si es el último slot no pongo la que apunta hacia abajo.

La funcionalidad de "subir" ya quedó OK, sin embargo la bajada nop..  :-\

Los parámetros que mando por cada registro en el link son:

Código:
order=down&id_banner=1&slot=1&idnextslot=2

Donde id_banner es el ID del registro, el slot es el número de slot que tiene y el idnextslot es el slot siguiente.

En mis querys tengo lo siguiente:

Código
  1. //--------------------------------------------------------------+
  2. // Case Down |
  3. //--------------------------------------------------------------+
  4. if($var['order']=="down"){
  5. //--------------------------------------------------------------+
  6. // First get the next Number ID slot and ID_banner |
  7. //--------------------------------------------------------------+
  8. $DBQuery->attrib['query'] = "SELECT id_banner, slot FROM `banner` WHERE `id_banner` ='".$var['idnextslot']."'";
  9. //echo $DBQuery->attrib['query']."<br>";
  10. $getNextSlot = $DBQuery->RunQuery();
  11.  
  12. //--------------------------------------------------------------+
  13. // Update the original entry with the new id_slot |
  14. //--------------------------------------------------------------+
  15. $DBQuery->attrib['query'] = "UPDATE `banner` SET `slot` = '".$var['idnextslot']."' WHERE `id_banner` ='".$var['id_banner']."'";
  16. //echo $DBQuery->attrib['query']."<br>";
  17. $downSlot=$DBQuery->RunQuery();
  18.  
  19. //--------------------------------------------------------------+
  20. // Update the entry target with the old slot |
  21. //--------------------------------------------------------------+
  22. $DBQuery->attrib['query'] = "UPDATE `banner` SET `slot` = '".$var['slot']."' WHERE `id_banner` ='".$getNextSlot[0]['id_banner']."'";
  23. //echo $DBQuery->attrib['query']."<br>";
  24. $downSlot=$DBQuery->RunQuery();
  25.  
  26. }
  27.  

Simplemente no funciona.. me actualiza los registros mal  :xD  :-\, me pone slot's elevados y a veces menores. A ver si me podeis echar un cable.. gracias  :)
293  Programación / PHP / Re: PHP5, El Lenguaje Para Los Profesionales De La Web en: 10 Julio 2009, 18:49 pm
Gracias.
294  Programación / PHP / Re: detectar salto de carro en caja de texto en: 9 Julio 2009, 20:24 pm
php? por qué no preguntaste ahí?? nl2br();...
295  Programación / PHP / Re: Error muy raro en: 9 Julio 2009, 02:23 am
raro?, no tenias el mysql corriendo...  ;-)

Si estaba corriendo O.o

Nop, o no lo tenias en el 3306 o el fw de windows te estaba bloqueando..
296  Programación / PHP / Re: Error muy raro en: 8 Julio 2009, 06:28 am
raro?, no tenias el mysql corriendo...  ;-)
297  Programación / PHP / Re: subir archivos via php en: 8 Julio 2009, 06:26 am
Usa $_FILES.
298  Programación / PHP / Re: tu como proteges tus aplicaciones php?? en: 2 Julio 2009, 20:50 pm
Sí, sí estaba mal XD pero ahí tiene la versión que funciona  :silbar:
299  Programación / PHP / Re: ¿Cómo hago include() a una web externa? en: 27 Junio 2009, 19:44 pm
RFI....
300  Programación / PHP / Re: Expresiones regulares (Ya me duele la cabeza) en: 27 Junio 2009, 19:40 pm
Si no tienes patrones repetidos en el string usa explode, Saludos.
Páginas: 1 ... 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 ... 138
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines