Ver Mensaje Individual
  #8 (permalink)  
Antiguo 09/08/2010, 19:41
Avatar de oscarios
oscarios
 
Fecha de Ingreso: septiembre-2004
Mensajes: 186
Antigüedad: 19 años, 7 meses
Puntos: 2
Respuesta: Ordenar consulta

Código PHP:
Ver original
  1. <?php require_once('Connections/conbanca.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. mysql_select_db($database_conbanca, $conbanca);
  35. $query_Recordset1 = "SELECT * FROM inmuebles order by $_GET['field'] $_GET['order']";
  36. $Recordset1 = mysql_query($query_Recordset1, $conbanca) or die(mysql_error());
  37. $row_Recordset1 = mysql_fetch_assoc($Recordset1);
  38. $totalRows_Recordset1 = mysql_num_rows($Recordset1);
  39. ?>
  40. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  41. <html xmlns="http://www.w3.org/1999/xhtml">
  42. <head>
  43. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  44. <title>Documento sin título</title>
  45. </head>
  46.  
  47. <body>
  48. <form id="form1" name="form1" method="get" action="prueba.php">
  49. <label>
  50. <select name="field" id="field">
  51. <option>Seleccione un campo</option>
  52. <option value="fecha">fecha</option>
  53. <option value="barrio">barrio</option>
  54. <option value="direccion">direccion</option>
  55. <option value="codigo_inm">codigo_inm</option>
  56. </select>
  57. </label>
  58. <label>
  59. <select name="order" id="order">
  60. <option selected="selected">Orden</option>
  61. <option value="ASC">Ascendente</option>
  62. <option value="DESC">Descendente</option>
  63. </select>
  64. </label>
  65. <label>
  66. <input type="submit" name="button" id="button" value="ORDENAR" />
  67. </label>
  68. </form>
  69. <p>&nbsp;</p>
  70. <table width="500" border="1" cellspacing="0" cellpadding="3">
  71. <tr>
  72. <td bgcolor="#909090">FECHA</td>
  73. <td bgcolor="#909090">BARRIO</td>
  74. <td bgcolor="#909090">DIRECCION</td>
  75. <td bgcolor="#909090">CODIGO</td>
  76. </tr>
  77. <?php do { ?>
  78. <tr>
  79. <td><?php echo $row_Recordset1['fecha']; ?></td>
  80. <td><?php echo $row_Recordset1['barrio']; ?></td>
  81. <td><?php echo $row_Recordset1['direccion']; ?></td>
  82. <td><?php echo $row_Recordset1['codigo_inm']; ?></td>
  83. </tr>
  84. <?php } while ($row_Recordset1 = mysql_fetch_assoc($Recordset1)); ?>
  85. </table>
  86. </body>
  87. </html>
  88. <?php
  89. mysql_free_result($Recordset1);
  90. ?>