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

Y ESTE ES EL CODIGO CON LOS CAMBIOS

Código PHP:
Ver original
  1. <?php require_once('Connections/conbanca.php'); ?>
  2. <?php
  3. if(!isset($_GET['field'])){
  4.  $_GET['field']='Id';
  5. }
  6. if (!function_exists("GetSQLValueString")) {
  7. function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
  8. {
  9.   if (PHP_VERSION < 6) {
  10.     $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
  11.   }
  12.  
  13.   $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
  14.  
  15.   switch ($theType) {
  16.     case "text":
  17.       $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
  18.       break;    
  19.     case "long":
  20.     case "int":
  21.       $theValue = ($theValue != "") ? intval($theValue) : "NULL";
  22.       break;
  23.     case "double":
  24.       $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
  25.       break;
  26.     case "date":
  27.       $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
  28.       break;
  29.     case "defined":
  30.       $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
  31.       break;
  32.   }
  33.   return $theValue;
  34. }
  35. }
  36.  
  37. $currentPage = $_SERVER["PHP_SELF"];
  38.  
  39. $maxRows_Recordset1 = 10;
  40. $pageNum_Recordset1 = 0;
  41. if (isset($_GET['pageNum_Recordset1'])) {
  42.   $pageNum_Recordset1 = $_GET['pageNum_Recordset1'];
  43. }
  44. $startRow_Recordset1 = $pageNum_Recordset1 * $maxRows_Recordset1;
  45.  
  46. $colname_Recordset1 = "-1";
  47. if (isset($_GET['ciudad'])) {
  48.   $colname_Recordset1 = $_GET['ciudad'];
  49. }
  50. $colpara_Recordset1 = "-1";
  51. if (isset($_GET['zona'])) {
  52.   $colpara_Recordset1 = $_GET['zona'];
  53. }
  54. $coltype_Recordset1 = "-1";
  55. if (isset($_GET['tipo'])) {
  56.   $coltype_Recordset1 = $_GET['tipo'];
  57. }
  58. $colrang_Recordset1 = "-1";
  59. if (isset($_GET['rango'])) {
  60.   $colrang_Recordset1 = $_GET['rango'];
  61. }
  62. mysql_select_db($database_conbanca, $conbanca);
  63. $query_Recordset1 = sprintf("SELECT inmuebles.foto_a, inmuebles.foto_b, inmuebles.foto_c, inmuebles.foto_d, inmuebles.foto_e, inmuebles.foto_f, inmuebles.ciudad, inmuebles.zona, inmuebles.barrio, inmuebles.direccion, inmuebles.tipo, inmuebles.valor, inmuebles.rango, inmuebles.area, inmuebles.habitaciones, inmuebles.codigo_inm, inmuebles.obs FROM inmuebles WHERE inmuebles.ciudad LIKE %s  AND inmuebles.zona LIKE %s  AND inmuebles.tipo LIKE %s  AND inmuebles.rango LIKE %s ORDER BY" .$_GET['field']." ".$_GET['order'];, GetSQLValueString($colname_Recordset1, "text"),GetSQLValueString($colpara_Recordset1, "text"),GetSQLValueString($coltype_Recordset1, "text"),GetSQLValueString($colrang_Recordset1, "text"));
  64. $query_limit_Recordset1 = sprintf("%s LIMIT %d, %d", $query_Recordset1, $startRow_Recordset1, $maxRows_Recordset1);
  65. $Recordset1 = mysql_query($query_limit_Recordset1, $conbanca) or die(mysql_error());
  66. $row_Recordset1 = mysql_fetch_assoc($Recordset1);
  67.  
  68. if (isset($_GET['totalRows_Recordset1'])) {
  69.   $totalRows_Recordset1 = $_GET['totalRows_Recordset1'];
  70. } else {
  71.   $all_Recordset1 = mysql_query($query_Recordset1);
  72.   $totalRows_Recordset1 = mysql_num_rows($all_Recordset1);
  73. }
  74. $totalPages_Recordset1 = ceil($totalRows_Recordset1/$maxRows_Recordset1)-1;
  75.  
  76. $queryString_Recordset1 = "";
  77. if (!empty($_SERVER['QUERY_STRING'])) {
  78.   $params = explode("&", $_SERVER['QUERY_STRING']);
  79.   $newParams = array();
  80.   foreach ($params as $param) {
  81.     if (stristr($param, "pageNum_Recordset1") == false &&
  82.         stristr($param, "totalRows_Recordset1") == false) {
  83.       array_push($newParams, $param);
  84.     }
  85.   }
  86.   if (count($newParams) != 0) {
  87.     $queryString_Recordset1 = "&" . htmlentities(implode("&", $newParams));
  88.   }
  89. }
  90. $queryString_Recordset1 = sprintf("&totalRows_Recordset1=%d%s", $totalRows_Recordset1, $queryString_Recordset1);
  91. ?>
  92. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  93. "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  94. <!-- saved from url=(0014)about:internet -->
  95. <html xmlns="http://www.w3.org/1999/xhtml">
  96. <head>
  97. <title>BANCA CENTRAL INMOBILIARIA CONVIERTA SU ARRIENDO EN CASA PROPIA!!!</title>
  98. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  99. <style type="text/css">td img {display: block;}body {
  100.     margin-left: 0px;
  101.     margin-top: 0px;
  102.     margin-right: 0px;
  103.     margin-bottom: 0px;
  104. }
  105. </style>
  106. <!--Fireworks CS3 Dreamweaver CS3 target.  Created Sun Aug 08 21:13:53 GMT-0500 2010-->
  107. <script language="JavaScript1.2" type="text/javascript">
  108. <!--
  109. function MM_preloadImages() { //v3.0
  110.   var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
  111.     var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
  112.     if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
  113. }
  114. //-->
  115. </script>
  116. <link href="imgs/bacanciSt.css" rel="stylesheet" type="text/css" />
  117. </head>
  118. <body>
  119. <table width="100%" border="0" cellspacing="0" cellpadding="3">
  120.   <tr>
  121.     <td width="219"><img src="imgs/Página 1.jpg" width="219" height="31" /></td>
  122.     <td colspan="2"><table width="10%" border="0" align="right" cellpadding="0" cellspacing="0">
  123.       <tr>
  124.         <td nowrap="nowrap"><span class="textoN">Usted encontro </span><span class="encabN"><?php echo $totalRows_Recordset1 ?> <?php echo $row_Recordset1['tipo']; ?></span></td>
  125.       </tr>
  126.     </table></td>
  127.   </tr>
  128.   <tr>
  129.     <td height="40"><table width="10%" border="0" cellpadding="0" cellspacing="0">
  130.       <tr>
  131.         <td nowrap="nowrap" class="textoN">Registros <?php echo ($startRow_Recordset1 + 1) ?> a <?php echo min($startRow_Recordset1 + $maxRows_Recordset1, $totalRows_Recordset1) ?> de <?php echo $totalRows_Recordset1 ?></td>
  132.       </tr>
  133.     </table></td>
  134.     <td width="450"><form id="form1" name="form1" method="get" action="result2.php">
  135.       <label>
  136.         <select name="field" id="field">
  137.           <option>Seleccione un campo</option>
  138.           <option value="fecha">fecha</option>
  139.           <option value="barrio">barrio</option>
  140.           <option value="direccion">direccion</option>
  141.           <option value="codigo_inm">codigo_inm</option>
  142.         </select>
  143.       </label>
  144.       <label>
  145.         <select name="order" id="order" method="get">
  146.           <option selected="selected">Orden</option>
  147.           <option value="ASC">Ascendente</option>
  148.           <option value="DESC">Descendente</option>
  149.         </select>
  150.       </label>
  151.       <label>
  152.         <input type="submit" name="button" id="button" value="Enviar" />
  153.       </label>
  154.     </form></td>
  155.     <td width="213"><table border="0" align="right">
  156.       <tr>
  157.         <td><?php if ($pageNum_Recordset1 > 0) { // Show if not first page ?>
  158.           <a href="<?php printf("%s?pageNum_Recordset1=%d%s", $currentPage, 0, $queryString_Recordset1); ?>"><img src="First.gif" border="0" /></a>
  159.           <?php } // Show if not first page ?></td>
  160.         <td><?php if ($pageNum_Recordset1 > 0) { // Show if not first page ?>
  161.           <a href="<?php printf("%s?pageNum_Recordset1=%d%s", $currentPage, max(0, $pageNum_Recordset1 - 1), $queryString_Recordset1); ?>"><img src="Previous.gif" border="0" /></a>
  162.           <?php } // Show if not first page ?></td>
  163.         <td><?php if ($pageNum_Recordset1 < $totalPages_Recordset1) { // Show if not last page ?>
  164.           <a href="<?php printf("%s?pageNum_Recordset1=%d%s", $currentPage, min($totalPages_Recordset1, $pageNum_Recordset1 + 1), $queryString_Recordset1); ?>"><img src="Next.gif" border="0" /></a>
  165.           <?php } // Show if not last page ?></td>
  166.         <td><?php if ($pageNum_Recordset1 < $totalPages_Recordset1) { // Show if not last page ?>
  167.           <a href="<?php printf("%s?pageNum_Recordset1=%d%s", $currentPage, $totalPages_Recordset1, $queryString_Recordset1); ?>"><img src="Last.gif" border="0" /></a>
  168.           <?php } // Show if not last page ?></td>
  169.       </tr>
  170.     </table></td>
  171.   </tr>
  172. </table>
  173. <?php do { ?>
  174.   <table width="100%" border="0" cellpadding="3" cellspacing="0" class="contmapa">
  175.     <tr>
  176.       <td width="152" rowspan="3" valign="top" bgcolor="#85C226"><a href="result3.php?codigo_inm=<?php echo $row_Recordset1['codigo_inm']; ?>"><img src="photos/<?php echo $row_Recordset1['foto_a']; ?>" width="152" height="100" border="0" /></a></td>
  177.       <td nowrap="nowrap" bgcolor="#85C226" class="encabN">Barrio</td>
  178.       <td nowrap="nowrap" bgcolor="#85C226" class="encabN">Valor venta</td>
  179.       <td nowrap="nowrap" bgcolor="#85C226" class="encabN">Area</td>
  180.       <td nowrap="nowrap" bgcolor="#85C226" class="encabN">Habit.</td>
  181.       <td nowrap="nowrap" bgcolor="#85C226" class="encabN">Código</td>
  182.       <td align="center" bgcolor="#FFFFFF">&nbsp;</td>
  183.     </tr>
  184.     <tr>
  185.       <td nowrap="nowrap" bgcolor="#FFFFFF" class="textoN"><?php echo $row_Recordset1['barrio']; ?></td>
  186.       <td nowrap="nowrap" bgcolor="#FFFFFF" class="textoN">$ <?php echo $row_Recordset1['valor']; ?></td>
  187.       <td nowrap="nowrap" bgcolor="#FFFFFF" class="textoN"><?php echo $row_Recordset1['area']; ?> &nbsp;mts2</td>
  188.       <td nowrap="nowrap" bgcolor="#FFFFFF" class="textoN"><?php echo $row_Recordset1['habitaciones']; ?></td>
  189.       <td nowrap="nowrap" bgcolor="#FFFFFF" class="textoN"><?php echo $row_Recordset1['codigo_inm']; ?></td>
  190.       <td align="center" bgcolor="#FFFFFF">&nbsp;</td>
  191.     </tr>
  192.     <tr class="textoN">
  193.       <td colspan="5" valign="top" bgcolor="#FFFFFF" class="linSup">mm</td>
  194.       <td align="center" bgcolor="#FFFFFF"><table width="10%" border="0" align="center" cellpadding="0" cellspacing="0">
  195.         <tr>
  196.           <td><a href="result3.php?codigo_inm=<?php echo $row_Recordset1['codigo_inm']; ?>"><img src="imgs/ingresar.png" width="100" height="25" border="0" /></a></td>
  197.           </tr>
  198.       </table></td>
  199.     </tr>
  200.   </table>
  201.   <br />
  202. <?php } while ($row_Recordset1 = mysql_fetch_assoc($Recordset1)); ?>
  203. </body>
  204. </html>
  205. <?php
  206. mysql_free_result($Recordset1);
  207. ?>