Foros del Web » Programación para mayores de 30 ;) » .NET »

Colocar un list/menu para elegir el order by...

Estas en el tema de Colocar un list/menu para elegir el order by... en el foro de .NET en Foros del Web. Buenas, les pido su ayuda tengo esta pagina de productos y quiero poner un list/menu para elegir el orden de productos asc o desc sin ...
  #1 (permalink)  
Antiguo 21/08/2013, 12:14
 
Fecha de Ingreso: febrero-2011
Mensajes: 2
Antigüedad: 13 años, 2 meses
Puntos: 0
Colocar un list/menu para elegir el order by...

Buenas, les pido su ayuda tengo esta pagina de productos y quiero poner un list/menu para elegir el orden de productos asc o desc sin salir de la pagina..esta es la pagina que muestra los productos.. help!!!
Código ASP:
Ver original
  1. <!--#include file="conection.asp"-->
  2. <%
  3. Dim mostrar 'cantidad de registros a mostrar por página
  4. Dim cant_paginas 'cantidad de páginas que recibimos
  5. Dim pagina_actual 'La página que mostramos
  6. Dim registro_mostrado 'Contador utilizado para mostrar las páginas
  7. Dim I 'Variable Loop
  8.  
  9. Dim bodega1, bodega2, bodega3
  10. bodega1 = "0000000006"
  11. bodega2 = "0000000009"
  12. bodega3 = "0000000011"
  13. bodega4 = "0000000022"
  14. orden1 = "asc"
  15. 'and s.ProductoID = p.ID and s.stock <> 0 and p.Marca != 'apple' "para borrar una marca"
  16.  
  17.         sSQL="select DISTINCT p.ID as ID, p.Código as Código, p.Ubicación as Ubicación, p.Nombre as Nombre, p.Marca as Marca, p.Descripción as Descripción, p.Precio1 as Precio1,p.Precio6 as Precio6, p.CAE as CAE from INV_PRODUCTOS p, INV_PD_BODEGA_STOCK s , inv_grupos g where g.id = p.grupoid and CHARINDEX ('"& Request.QueryString("App") &"',g.ruta) > 0 and s.ProductoID = p.ID and s.stock <> 0 and p.grupoid != '0000000057' and s.ProductoID = p.ID and s.stock <> 0 and p.grupoid != '0000000086'  and s.ProductoID = p.ID and s.stock <> 0 and p.Marca != 'IBM' and s.ProductoID = p.ID and s.stock <> 0 and p.Código != '19EN33S' and (s.bodegaID = '"& bodega1 &"' or s.bodegaID = '"& bodega2 &"' or s.bodegaID = '"& bodega3 &"' or s.bodegaID = '"& bodega4 &"') Order by Precio1 desc"
  18. 'esta sentencia SQL puede ser creada a partir de un buscador como el que hemos visto en otro reportaje
  19. 'y almacenada en una session para emplearla sucesivas veces en el script: session("ssql")=ssql 1"
  20.  
  21. mostrar = 12 ' Pueden modificar este número para cambiar la cantidad de registros por página
  22.  
  23. ' IF para saber que página mostrar
  24. If Request.QueryString("page") = "" Then
  25. pagina_actual = 1
  26. Else
  27. pagina_actual = CInt(Request.QueryString("page"))
  28. End If
  29.  
  30. Set Conn = Server.CreateObject("ADODB.Connection")
  31.  
  32. ' Creamos el RecordSet y definimos la cantidad de registros a mostrar
  33. Set RS = Server.CreateObject("ADODB.Recordset")
  34. RS.PageSize = mostrar
  35. RS.CacheSize = mostrar
  36.  
  37. ' Abrimos la tabla...
  38. RS.Open sSQL, oConn,3,1
  39. 'contamos las páginas que se formaron con la variable mostrar.
  40. cant_paginas = RS.PageCount
  41.  
  42. ' Si el pedido de página cae afuera del rango,
  43. ' lo modificamos para que caiga adentro
  44. If pagina_actual > cant_paginas Then pagina_actual = cant_paginas
  45. If pagina_actual < 1 Then pagina_actual = 1
  46.  
  47. ' Si la cantidad de páginas da 0 es que no hay registros... por eso este IF
  48. If cant_paginas = 0 Then
  49. Response.Redirect("notDataFound.asp")
  50. Else
  51. ' Nos movemos a la página elegida
  52. RS.AbsolutePage = pagina_actual
  53. ' Mostramos el dato de que página estamos...
  54.  
  55.  
  56. Dim precio
  57.  
  58. If Not RS.EOF Then
  59.  
  60. %>
  61.  
  62.  
  63. <table width="100%" border="0" cellpadding="0" cellspacing="0">
  64. <!--DWLayoutTable-->
  65. <tr>
  66. <td width="210" height="6"></td>
  67. <td width="11"></td>
  68. <td width="210"></td>
  69. <td width="11"></td>
  70. <td width="214"></td>
  71. </tr>
  72. <tr>
  73. <td height="5" colspan="5" align="center" valign="middle">
  74. <img src="http://www.forosdelweb.com/f86/images/products_03Bar.jpg" width="652" height="5" border="0" /></td>
  75. </tr>
  76. <tr>
  77. <td height="153" valign="top">
  78. <%
  79.     precio = 0 
  80.     registro_mostrado = 0
  81.     precio5=0
  82.     preciom=0
  83.    
  84.     Do While registro_mostrado < mostrar And Not RS.EOF    
  85.         registro_mostrado = registro_mostrado + 1
  86.            
  87.         If Session("usuario") = False Then
  88.             preciom = RS.Fields("Precio1").Value
  89.            
  90.         precion=preciom / 0.87     
  91.         precio=precion
  92.         Else
  93.             preciom = rs.Fields("Precio1").Value
  94.         precio5=preciom / 0.95
  95.        
  96.         precio=precio5
  97.             'precio = RS.Fields("Precio1").Value
  98.         End If
  99.        
  100.         if ((registro_mostrado -1) mod 3) = 0 and registro_mostrado <> 1 Then
  101.             Response.Write("<tr /><td height='153' valign='top'>")
  102.         end if
  103. %>
  104.  
  105. <table width="100%" border="0" cellpadding="0" cellspacing="0">
  106.   <!--DWLayoutTable-->  
  107.   <tr>
  108.     <td width="13" height="5"></td>
  109.       <td width="96"></td>
  110.       <td width="4"></td>
  111.       <td width="97"></td>
  112.   </tr>
  113.   <tr>
  114.     <td height="14"></td>
  115.     <td rowspan="6" align="center" valign="middle" class="borderProducts"><%if RS.Fields("CAE").Value <> "" Then %>
  116.     <a href="productOnce.asp?App=<% =RS.Fields("ID").Value %>">
  117.     <img src="http://www.forosdelweb.com/f86/upload/<%= RS.Fields("CAE").Value%>" width="94" height="101" border="0" />
  118.     <%Else%>
  119.     <img src="http://www.forosdelweb.com/f86/upload/NO_DISPONIBLE_PE.jpg" width="94" height="101" border="0" />
  120.     <%End If%>    </td>
  121.       <td></td>
  122.       <td valign="top" class="textRed12"><b class="textIDProduct"><%= RS.Fields("Código").Value %></b> </td>
  123.   </tr>
  124.   <tr>
  125.     <td height="13"></td>
  126.     <td></td>
  127.     <td valign="top" class="textRed11"><b>Marca:</b></td>
  128.   </tr>
  129.   <tr>
  130.     <td height="21"></td>
  131.     <td></td>
  132.     <td align="center" valign="middle" class="textNormal11"><b><%= Left(RS.Fields("Marca").Value,16) %></b></td>
  133.   </tr>
  134.   <tr>
  135.     <td height="13"></td>
  136.     <td></td>
  137.     <td valign="top" class="textRed11"><b>Precio:</b></td>
  138.   </tr>
  139.   <tr>
  140.     <td height="13"></td>
  141.     <td></td>
  142.     <td align="center" valign="middle" class="textNormal11"><b><%= formatNumber(precio,2) %></b></td>
  143.   </tr>
  144.   <tr>
  145.     <td height="29"></td>
  146.     <td></td>
  147.     <td align="left" valign="bottom"><a href="productOnce.asp?App=<% =RS.Fields("ID").Value %>">
  148.     <img src="http://www.forosdelweb.com/f86/images/view_Detail.jpg" width="67" height="20" border="0" /></a>
  149. <%    If session("usuario") = False  Then
  150.                 Response.Write("<!--DWLayoutEmptyCell-->&nbsp;")
  151.               Else %>
  152.     <a href="productOnce.asp?App=<% =RS.Fields("ID").Value %>">
  153.     <img src="http://www.forosdelweb.com/f86/images/carritoC.jpg" width="24" height="18" border="0" /></a><%End If%></td>
  154.   </tr>
  155.   <tr>
  156.     <td height="4"></td>
  157.     <td></td>
  158.     <td></td>
  159.     <td></td>
  160.   </tr>
  161.   <tr>
  162.     <td height="41"></td>
  163.     <td colspan="3" align="center" valign="top" class="labelDescripcionProduct"><%= Left(RS.Fields("Nombre").Value,30) %></td>
  164.     </tr>  
  165. </table>
  166. <td>&nbsp;</td><td height='153' valign='top'>
  167. <%
  168.     ' Nos movemos al próximo registro...
  169.     RS.MoveNext
  170. Loop
  171.  
  172. Else
  173.     Response.Redirect("notDataFound.asp")
  174. End If
  175. %>
  176. </table>
  177. <table width="100%" border="0" cellpadding="0" cellspacing="0">
  178.     <tr>
  179.         <td width="656" height="20" align="right" valign="middle" class="ubicacion">P&aacute;gina:&nbsp;&nbsp;&nbsp;&nbsp;
  180. <%      'Ahora mostramos los enlaces a las otras páginas con el resto de los registros...
  181. If pagina_actual > 1 Then
  182. %>
  183. <a href="products_menu.asp?App=<%=Request.QueryString("App")%>&page=<%= pagina_actual - 1 %>"><span class="ubicacion">[<< Anterior]</span></a>
  184. <%
  185. End If
  186.  
  187. ' mostramos la paginacion por numeros de página
  188. For I = 1 To cant_paginas
  189. If I = pagina_actual Then
  190. %>
  191. <%= I %>
  192. <%
  193. Else
  194. %>
  195. <a href="products_menu.asp?App=<%=Request.QueryString("App")%>&page=<%=I%>"><%= I %></a>
  196. <%
  197. End If
  198. Next 'I
  199.  
  200. If pagina_actual < cant_paginas Then
  201. %>
  202. <a href="products_menu.asp?App=<%=Request.QueryString("App")%>&page=<%= pagina_actual + 1 %>"><span class="ubicacion">[Siguiente >>]</span></a>
  203. <%
  204. End If
  205. 'Fin...
  206. %></td>
  207.     </tr>
  208. </table>
  209. <%
  210. End If
  211. RS.Close
  212.  
  213. %>

Última edición por gnzsoloyo; 21/08/2013 a las 12:56

Etiquetas: elegir, list-menu, mysql, order, registro, registros, select, sql, tabla
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 00:26.