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