Ver Mensaje Individual
  #3 (permalink)  
Antiguo 22/10/2004, 11:14
herrezuelo
 
Fecha de Ingreso: abril-2004
Ubicación: Madrid
Mensajes: 159
Antigüedad: 20 años
Puntos: 0
ok, ahi va

<html>
<head>
<title>Resultados busqueda</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>
<?
if (! isset($tipo)) exit();
require('ad/config/config.inc');

function Pie_Movimiento_paginas(){
?>
<tr>
<td colspan="8">
<table width="100%" cellpadding="0" cellspacing="0">
<tr>
<td style="background-color:#CC0000;color:white" align="right" class="texto_negro_bold">
<strong><font face="Verdana, Arial, Helvetica, sans-serif"><strong><font size="1"><em>
Ir a pagina
</em></font></strong></font></strong>
<input type="text" class="cajas" name="numerodepagina" size="4" maxlength="4">
</td>
</tr>
</table>
</td>
</tr>
<?
}

function Busqueda_Sin_Resultados(){//Esta funcion devuelve pinta la fila cuando la busqueda no produce resultados
?>
<tr>
<td colspan="8" style="width:100%;height:100%;background-color:#F2F1E6" align="center" class="texto_negro_bold">
<strong><font face="Verdana, Arial, Helvetica, sans-serif"><strong><font size="1"><em>
La busqueda no produjo resultados
</em></font></strong></font></strong>
</td>
</tr>
<?
}
function Pie_Mostrando_resultados(){
?>
<td colspan="8" style="background-color:#CC0000;color:white" align="center" class="texto_negro_bold">
<strong><font face="Verdana, Arial, Helvetica, sans-serif"><strong><font size="0"><em>
Mostrando resultados del <? echo $inicio; ?> al <? echo $contador; ?>.
</em></font></strong></font></strong>
</td>
<?
}
function Cabecera_Informacion_Resultados(){
?>
<td colspan="8" style="background-color:#CC0000;color:white" align="center" class="texto_negro_bold">
<strong><font face="Verdana, Arial, Helvetica, sans-serif"><strong><font size="0"><em>
Se han encuntrado <? echo $numresultados; ?> personas con las caracteristicas buscadas.
</em></font></strong></font></strong>
</td>
<?
}

function Pinta_Celda_Dato($texto){
?>
<td style="background-color:#F2F1E6" align="center" class="texto_negro_bold">
<strong><font face="Verdana, Arial, Helvetica, sans-serif"><strong><font size="1"><em>
<? echo $texto; ?>
</em></font></strong></font></strong>
</td>
<?
}
function Pinta_Celda_Cabecera($texto){//pinta una celda de la cabecera con el texto que el pasemos
?>
<td style="cursor:hand;background-color:#CC0000;color:white" bordercolor="#000000" align="justify" class="texto_negro_bold">
<strong><font face="Verdana, Arial, Helvetica, sans-serif"><strong><font size="2"><em>
<? echo $texto; ?>
</em></font></strong></font></strong>
</td>
<?
}
function Cabecera_resultados(){ //CODIGO HTML QUE DIBUJA LA CABECERA DE LA TABLA DE RESULTADOS (LA FILA 1)
$Textos_Cabecera = array("Nombre","Apellidos","Sexo","Nick","Nacional idad","Fecha nacimiento","Email","Teléfono");
?> <tr> <?
for ($i=0;$i<= count($Textos_Cabecera)-1;$i++) Pinta_Celda_Cabecera("$Textos_Cabecera[$i]");
?> </tr><?
}

function Construir_SQL_buscadorbasico(){ //Contruye una SQL de busqueda con los datos del buscador basico
global $min_edad;global $max_edad;global $nacionalidad;global $sexo;

$ano_ini = (date("Y") - $min_edad)."-01-"."01";
$ano_fin = (date("Y") - $max_edad)."-01-"."01";
$str_sql_busqueda = "SELECT * from usuarios where nacionalidad like '%$nacionalidad%' AND sexo like '%$sexo%' AND (fechanacimiento BETWEEN '$ano_ini' AND '$ano_fin' OR fechanacimiento BETWEEN '$ano_fin' AND '$ano_ini')";
return $str_sql_busqueda;
}

function Contruir_SQL_buscadoravanzado(){// construye la sql de busqueda con los datos del buscador avanzado
global $nombre;global $apellidos;global $nick;global $fumador;global $edad1;global $edad2;global $nacionalidad;global $hijos;global $estadocivil;global $email;global $telefono;global $religion;global $sexo;
global $complexion;global $peso1;global $peso2;global $altura1;global $altura2;global $cabello;global $ojos;global $tez;global $estilo;
global $ciudad;global $provincia;global $cp;global $direccion;
global $estudios;global $profesion;global $ingresos;
global $gusto;global $preferencias;global $otros;

// -------------------- DATOS PERSONALES
if ($telefono=="")$telefono="%";
if ($email=="")$email="%";
if ($edad1=="%")$edad1=5;
if ($edad2=="%")$edad2=200;
if ($edad1 != "%")$edad1 = (date("Y") - $edad1)."-01-"."01";
if ($edad2 != "%")$edad2 = (date("Y") - $edad2)."-01-"."01";
$strsql_datos_personales = "nombre like '%$nombre%' and apellidos like '%$apellidos%' and nick like '%$nick%' and fumador like '$fumador' and (fechanacimiento between '$edad1' and '$edad2' or fechanacimiento between '$edad2' and '$edad1') and nacionalidad like '$nacionalidad' and hijos like '$hijos' and estadocivil like '$estadocivil' and email like '$email' and telefono like '$telefono' and religion like '$religion' and sexo like '$sexo'";
// -------------------- DATOS FISICOS
if ($peso1=="%") $peso1=0;
if ($peso2=="%") $peso2=300;
if ($altura1=="%") $altura1=0;
if ($altura2=="%") $altura2=300;
$strsql_datos_fisicos = "constitucion like '$complexion' and (peso between '$peso1' and '$peso2' or peso between '$peso2' and '$peso1') and (altura between '$altura1' and '$altura2' or altura between '$altura2' and '$altura1') and cabello like '$cabello' and ojos like '$ojos' and tez like '$tez' and estilo like '$estilo'";
// -------------------- DATOS DE RESIDENCIA
$strsql_datos_residencia = "ciudad like '$ciudad' and provincia like '$provincia' and cp like '$cp' and direccion like '$direccion'";
// -------------------- DATOS PROFESIONALES
$strsql_datos_profesionales = "estudios like '$estudios' and profesion like '$profesion' and ingresos like '$ingresos'";
// -------------------- DATOS GUSTOS
//######### seleccion de ids de usuario con los gustos especificados
if (count($gusto)==0) {
$str="idgusto like '%'";
$str_gustosusuario="select distinct(idusuario) from gustosusuario where $str";
}
else{
for ($i=0;$i<=count($gusto)-1;$i++){
(($i+1)==count($gusto)) ? $str= $str."idgusto like '$gusto[$i]'":$str=$str."idgusto like '$gusto[$i]' or ";
}
$str_gustosusuario="select distinct(idusuario) from gustosusuario where $str";
}
$cursor=mysql_query ($str_gustosusuario);
if (! mysql_num_rows($cursor)){
$str_usuario_gusto="id like '%'";
}
else{
while ($registro = mysql_fetch_array($cursor)){
$str_usuario_gusto=$str_usuario_gusto."id = '$registro[idusuario]' or ";
}
$str_usuario_gusto=substr($str_usuario_gusto,0,str len($str_usuario_gusto)-4);
if (count($gusto)==0) {$str_usuario_gusto="id like '%'";}
}
//######### Fin seleccion de ids de usuario con los gustos especificados
$strsql_datos_gustos="($str_usuario_gusto) and preferencias like '$preferencias' and otros like '%$otros%'";
//echo $strsql_datos_gustos;

//SQL DE BUSQUEDA
$str_sql_busqueda = "select * from usuarios where ($strsql_datos_personales) AND ($strsql_datos_fisicos) AND ($strsql_datos_residencia) AND ($strsql_datos_profesionales) AND ($strsql_datos_gustos)";
return $str_sql_busqueda;
}









// ************************************** MAIN ********************************************

if ($tipo=="buscadoravanzado"){// *************************** SE TRATA DE UNA BUSKEDA DESDE EL BUSCADOR AVANZADO *********************
$SQL_BUSQUEDA=Contruir_SQL_buscadoravanzado();
}
if ($tipo=="buscadorbasico"){// *************************** SE TRATA DE UNA BUSKEDA DESDE EL BUSCADOR BASICO *********************
$SQL_BUSQUEDA=Contruir_SQL_buscadorbasico();
}

$campo_orden="nombre";
$tipo_orden="ASC";
$inicio=1;
$cantidad=20;
$SQL_BUSQUEDA=$SQL_BUSQUEDA." order by $campo_orden $tipo_orden limit $inicio,$cantidad";
//echo $SQL_BUSQUEDA;
$cursor=mysql_query($SQL_BUSQUEDA);

$Datos_Visibles = array("nombre","apellidos","sexo","nick","nacional idad","fechanacimiento","email","telefono");
?><table width="90%" border="0" align="center"><?
Cabecera_Informacion_Resultados();
Cabecera_Resultados();
if (! mysql_num_rows($cursor)){
Busqueda_Sin_Resultados();
}
else{
?><div style="background-color:#CC0000;overflow:scroll;overflow-x:hidden;height:200 px;"><?
while ($registro_usuario = mysql_fetch_array($cursor)){
//$sql_provincias="select * from provincias where codprovincia=$registro_usuarios[provincia]";
//$cursor_provincias=mysql_query($sql_provincias);
//$registro_provincias=mysql_fetch_array($cursor_pro vincias);
?><tr><?
for ($i=0;$i<=count($Datos_Visibles)-1;$i++) Pinta_Celda_Dato($registro_usuario[$Datos_Visibles[$i]]);
?></tr><?
?><tr><?

?></tr><?

}
?></div><?
Pie_Mostrando_resultados();
Pie_Movimiento_paginas();
}

?>
</table>

</body>
</html>