Ver Mensaje Individual
  #1 (permalink)  
Antiguo 17/05/2010, 11:44
den_22
 
Fecha de Ingreso: enero-2010
Mensajes: 198
Antigüedad: 14 años, 3 meses
Puntos: 1
Echo donde va?

Hola amigos tengo una duda, quiero que si no se encuentran resultados aparezca el tipico mensaje no se han encontrado resultados, el tema es que lo pongo pero no pasa nada.

Código PHP:
Ver original
  1. <?php
  2.  
  3.  
  4.  
  5.  
  6. $id=$_SESSION["id"];
  7. $usuario=$_SESSION["usuario"];
  8. $pag=$_REQUEST['pag'];
  9.  
  10.  
  11.  
  12.  
  13. include_once ("connect.php");
  14.  
  15.  
  16.  
  17.  
  18. $sexo = (!empty($_POST["sexo"])
  19.     ? " sexo='".trim($_POST["sexo"])."'"
  20.         : "");
  21.  
  22. $interestin = (!empty($_POST["interestin"])
  23.         ? (!empty($sexo)
  24.                 ? " AND interestin='".trim($_POST["interestin"])."'"
  25.                 : " interestin='".trim($_POST["interestin"])."'")
  26.         : "");
  27.  
  28. $pais = (!empty($_POST["pais"])
  29.         ? (!empty($sexo) || !empty($interestin)
  30.                 ? " AND pais='".trim($_POST["pais"])."'"
  31.                 : " pais='".trim($_POST["pais"])."'")
  32.         : "");
  33.  
  34. $estadocivil= (!empty($_POST["estadocivil"])
  35.         ? (!empty($sexo) || !empty($interestin) || !empty($pais)
  36.                 ? " AND estadocivil='".trim($_POST["estadocivil"])."'"
  37.                 : " estadocivil='".trim($_POST["estadocivil"])."'")
  38.         : "");
  39.  
  40.  
  41.  
  42. $where = (!empty($sexo) || !empty($interestin) || !empty($pais) || !empty($estadocivil)  
  43.         ? " WHERE "
  44.         : "");
  45.  
  46.  
  47.  
  48. if (!isset($pag)) $pag = 1; // Por defecto, pagina 1
  49. $result = mysql_query("SELECT COUNT(*) FROM members");
  50. list($total) = mysql_fetch_row($result);
  51. $tampag = 5;
  52. $reg1 = ($pag-1) * $tampag;
  53.  
  54. function paginar($actual, $total, $por_pagina, $enlace) {
  55.   $total_paginas = ceil($total/$por_pagina);
  56.   $anterior = $actual - 1;
  57.   $posterior = $actual + 1;
  58.   if ($actual>1)
  59.     $texto = "<a href=\"$enlace$anterior\">&laquo;</a> ";
  60.   else
  61.     $texto = "<b>&laquo;</b> ";
  62.   for ($i=1; $i<$actual; $i++)
  63.     $texto .= "<a href=\"$enlace$i\">$i</a> ";
  64.   $texto .= "<b>$actual</b> ";
  65.   for ($i=$actual+1; $i<=$total_paginas; $i++)
  66.     $texto .= "<a href=\"$enlace$i\">$i</a> ";
  67.   if ($actual<$total_paginas)
  68.     $texto .= "<a href=\"$enlace$posterior\">&raquo;</a>";
  69.   else
  70.     $texto .= "<b>&raquo;</b>";
  71.   return $texto;
  72. }
  73.  
  74.  
  75. $s = "SELECT * FROM members "
  76.         . $where
  77.         . $sexo
  78.         . $interestin
  79.         . $pais
  80.         . $estadocivil
  81.         ." LIMIT $reg1, $tampag";
  82.  
  83.  
  84.  
  85.  
  86. $query = mysql_query($s) or die(mysql_error());
  87.  
  88.  
  89.  
  90.  
  91.  
  92. while($row = mysql_fetch_array($query)) {
  93.  
  94.  
  95.        
  96.  
  97.            
  98.  
  99.  
  100. ?>

despues va el html
y al final cuando cierro el while , pongo :

Código PHP:
Ver original
  1. if( empty($sexo) || empty($interestin) || empty($pais) || empty($estadocivil)){
  2. echo "No se han encontrado resultados";
  3. }

Tengo que ponerlo mas arriba el codigo?