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

mira esta es la pagina en la que estoy tratando de hacer lo que me dices
http://www.bancaci.com/prueba.php

y este es el codigo!!!

<?php require_once('Connections/conbanca.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
if (PHP_VERSION < 6) {
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
}

$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}

mysql_select_db($database_conbanca, $conbanca);
$query_Recordset1 = "SELECT * FROM inmuebles order by $_GET['field'] $_GET['order']";
$Recordset1 = mysql_query($query_Recordset1, $conbanca) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Documento sin título</title>
</head>

<body>
<form id="form1" name="form1" method="get" action="prueba.php">
<label>
<select name="field" id="field">
<option>Seleccione un campo</option>
<option value="fecha">fecha</option>
<option value="barrio">barrio</option>
<option value="direccion">direccion</option>
<option value="codigo_inm">codigo_inm</option>
</select>
</label>
<label>
<select name="order" id="order">
<option selected="selected">Orden</option>
<option value="ASC">Ascendente</option>
<option value="DESC">Descendente</option>
</select>
</label>
<label>
<input type="submit" name="button" id="button" value="ORDENAR" />
</label>
</form>
<p>&nbsp;</p>
<table width="500" border="1" cellspacing="0" cellpadding="3">
<tr>
<td bgcolor="#909090">FECHA</td>
<td bgcolor="#909090">BARRIO</td>
<td bgcolor="#909090">DIRECCION</td>
<td bgcolor="#909090">CODIGO</td>
</tr>
<?php do { ?>
<tr>
<td><?php echo $row_Recordset1['fecha']; ?></td>
<td><?php echo $row_Recordset1['barrio']; ?></td>
<td><?php echo $row_Recordset1['direccion']; ?></td>
<td><?php echo $row_Recordset1['codigo_inm']; ?></td>
</tr>
<?php } while ($row_Recordset1 = mysql_fetch_assoc($Recordset1)); ?>
</table>
</body>
</html>
<?php
mysql_free_result($Recordset1);
?>