|    
			
				16/11/2007, 00:05
			
			
			  | 
  |   |  |  |  |  Fecha de Ingreso: enero-2007 Ubicación: Capital Federal, Argentina 
						Mensajes: 137
					 Antigüedad: 18 años, 9 meses Puntos: 2 |  | 
  |  Re: Ordenar resultados de una consulta  
  <?php $H1 = $_POST['H1']; // Campo "Tipo"
 $H2 = $_POST['H2']; // Campo "Calificacion"
 $H3 = $_POST['H3']; // Campo "Deposito"
 
 
 // Si no se selecciona calificacion
 if ($H2 == "") {
 $resProd = " SELECT * FROM `tabla` WHERE (P_tipo = '$H1' AND P_deposito = '$H3') ORDER BY P_calif DESC";
 // Si selecciona calificacion
 } else {
 $resProd = " SELECT * FROM `tabla` WHERE (P_tipo = '$H1' AND P_calif = '$H2' AND P_deposito = '$H3') ORDER BY P_nombre";
 }
 // Definimos la variable de Conexion
 $con=mysql_connect("","","");
 
 // Ingresamos en la BD
 mysql_select_db("BD",$con);
 // Ejecutamos las sentencias
 $rH = mysql_query($resProd, $con) or die(mysql_error());
 $num_total_registros = mysql_num_rows($rH);
 
 // Ponemos el número de registros total, el tamaño de página y la página que se muestra
 if ($num_total_registros == 0) {
 echo "Lo lamentamos pero su búsqueda no ha arrojado ningún resultado.<br>Por favor, modifique las opciones seleccionadas.<br> </td></tr><tr><td align='center'>";
 $include = include('./form_search.phtml');
 $function = Form_search();
 // Limpiamos resultados y cerramos la conexión
 mysql_free_result($rH);
 mysql_close($con);
 } else {
 $color = true;
 echo "<table width='490' border='0' cellpadding='0' cellspacing='0'><tr><td>Resultados encontrados:</td></tr>";
 echo "<tr><td align='center' height='20'><img src='./Images/bar.gif' border='0' width='490' height='1'></td></tr><tr><td align='center'>";
 echo "<table width='490' border='0' cellpadding='0' cellspacing='0'>";
 //
 while ($row = mysql_fetch_array($rH)){
 echo "<tr><td>".$row[P_calif]."</td></tr>";
 echo "<tr height='20'";
 if ($color == true) {
 echo " class='result1'>";
 $color = false;
 } else {
 echo " class='result2'>";
 $color = true;
 }
 echo "<td width='190'> ".$row[P_nombre]."</td><td width='200'>$".$row[P_precio]."</td><td width='90' align='center'>Stock: ".$row[P_stock]."</td><td width='10'><input type='checkbox' name='' value=""></td></tr>";
 }
 echo "</table><tr><td align='center' height='20'><img src='./Images/bar.gif' border='0' width='490' height='1'></td></tr>";
 echo "<tr><td class='observacion2'>Redefinir su búsqueda:</td></tr>";
 echo "<tr><td height='20' colspan='3'> </td></tr><tr><td align='center'>";
 $include = include('./form_search.phtml');
 $function = Form_search();
 echo "</td></tr>";
 //
 mysql_free_result($rH);
 mysql_close($con);
 }
 
 ?>
 
 con esta forma a cada fila le agrega la calificacion, yo quiero que los que tienen la misma, queden en conjunto bajo su calificacion, mostrada 1 vez al principio del conjunto...
     |