Ver Mensaje Individual
  #1 (permalink)  
Antiguo 20/04/2012, 06:00
carolina3
 
Fecha de Ingreso: agosto-2011
Ubicación: barcelona
Mensajes: 237
Antigüedad: 13 años, 7 meses
Puntos: 1
ordenar un listado según valor de registro

hola no se si el titulo indica lo que quiero pero bueno lo suelto;

tengo un registro en la base de datos y estoy intentando ordenar los registros según un campo que llamo control y que lo divido en 3 secciones (sección1, sección2, sección3) y no se como ordenar para que me ordene los productos en filas según su sección me salen todos salteados, como puedo indicarle para que me salga como quiero.

este es mi código

Código PHP:
Ver original
  1. <?php
  2.  $tienda= "tienda: " . $_GET["tienda"];
  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. $colname_listadoproductos = "-1";
  35. if (isset($_GET['tienda'])) {
  36.   $colname_listadoproductos = $_GET['tienda'];
  37. }
  38. mysql_select_db($database_blueberryswebtiendas, $blueberryswebtiendas);
  39. $query_listadoproductos = sprintf("SELECT * FROM productos WHERE tienda = %s", GetSQLValueString($colname_listadoproductos, "text"));
  40. $listadoproductos = mysql_query($query_listadoproductos, $blueberryswebtiendas) or die(mysql_error());
  41. $row_listadoproductos = mysql_fetch_assoc($listadoproductos);
  42. $totalRows_listadoproductos = mysql_num_rows($listadoproductos);
  43.  
  44.  
  45.  
  46. ?>
  47.  
  48.  
  49.  
  50.  
  51.  
  52.  
  53. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  54. <html xmlns="http://www.w3.org/1999/xhtml">
  55. <head>
  56. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  57. <title>mis productos</title>
  58. <link href="../estiloaccesousuarios.css" rel="stylesheet" type="text/css" />
  59.  
  60. </head>
  61.  
  62. <body>
  63. <div id="contenedor" >
  64.  
  65. <div id="contenido">
  66. <table width="746" border="1" cellspacing="0">
  67.   <tr>
  68.     <td colspan="4">Listado de productos</td>
  69.     </tr>
  70.  
  71.     <tr>
  72.       <td width="122">producto</td>
  73.       <td width="100">categoria</td>
  74.       <td width="124">nº de existencias<?php echo $row_listadoproductos['tienda']; ?></td>
  75.       <td width="212">tienda</td>
  76.     </tr>
  77.     <?php do { ?>
  78. <tr>
  79.   <td><?php echo $row_listadoproductos['nombre_producto']; ?></td>
  80.     <td><?php echo $row_listadoproductos['control']; ?></td>
  81.     <td><?php echo $row_listadoproductos['existencias_producto']; ?></td>
  82.   <td>&nbsp;</td>
  83. </tr>
  84. <?php } while ($row_listadoproductos = mysql_fetch_assoc($listadoproductos)); ?>
  85. </table>
  86.  
  87. </div>
  88.  
  89. </div>
  90. </body>
  91. </html>
  92. <?php
  93. mysql_free_result($listadoproductos);
  94. ?>

gracias