Buscador en php
Hola tengo el siguiente formulario ste es el archivo buscar.php
<?
include('conexion.php');
if(isset($_POST['buscar']))
{ $a=$_POST['especialidad'];
$b=$_POST['estados'];
$c=$_POST['municipios'];
$d=strtoupper($_POST['servicios']);
$sql="select idmedico from medicos WHERE idespecialidad=$a AND idestado=$b AND idmunicipio=$c and servicios LIKE '%".$d."%'; ";
$rs =@mysql_query($sql,$link);
$cantReg=@mysql_num_rows($rs);
if($cantReg == 0)
{
echo('
<p> No se encontro ningun resultado </p>
');
}
else
{
echo('
<p>
<a href="ResultadoMedicos.php?esp='.$a.'&est='.$b.'&mun='.$c.'&serv='.$d.'" target="_self">HAY '.$cantReg.' RESULTADOS</a><img src="imagenes/resultados.png" width="25" height="25"/> </p>
');
}
}
?>
st es el archivo resultadomedicos.php
<?
$tamanoPagina=5;
if ( isset($_GET['inicio']))
{
$inicio=$_GET['inicio'];
}
else
{
$inicio=0;
}
include("conexion.php");
$link=Conectarse();
$idesp =$_GET['esp'];
$idest =$_GET['est'];
$idmun =$_GET['mun'];
$servi =$_GET['servicios'];
$sql="SELECT nombre, appaterno,apmaterno,cedulaprofesional,idespecialidad,servicios,calle,numero,colonia,idestado,idmunicipio,cp,horarioconsulta,telefono,celular,email FROM medicos
WHERE
medicos.idestado=".$idest." AND medicos.idmunicipio=".$idmun." AND medicos.idespecialidad=".$idesp." LIMIT $inicio,$tamanoPagina";
//echo($sql);
$sql = mysql_query($sql) or die(mysql_error());
$numReg=mysql_num_rows($sql);
//PAGINACION ARRIBA
creaPaginacion($numReg ,$tamanoPagina,$idest,$idmun,$idcat);
while($matriz=mysql_fetch_array($sql))
{
echo(" Nombre: <span class='Estilo1'><a href='DescripcionEmpresas.php?empr=".$matriz['idempresa']."' target='_blank'>".$matriz['nomempresa']."</a></span>
Vacantes: ");
//CODIGO PARA ADMNISTRAR LA PAGINACION DEL CATALOGO
$tamanoPagina=3;
if ( isset($_GET['inicio']))
{
$inicio=$_GET['inicio'];
}
else
{
$inicio=0;
}
//FIN
//UNA FUNCION PARA CREAR UNA PAGINACION OPCION UNO
function creaPaginacionUno($cantidad,$tamanoPagina,$idmed,$idesp,$idest,$idmun,$servi)
{
$limite=0;
$end =ceil($cantidad / $tamanoPagina) + 1;
for($begin=0; $begin < $end; $begin ++ )
{
echo("<a href='ResultadoMedicos.php?inicio=$limite&esp=$idesp&est=$idest&mun=$idmun&servicios=$servi'>[$begin]</a> \n");
$limite=$limite + $tamanoPagina;
}
}
//FIN FUNCION
//UNA FUNCION PARA CREAR UNA PAGINACION OPCION DOS
function creaPaginacionDos($cantidad,$tamanoPagina,$idmed,$idesp,$idest,$idmun,$servi)
{
$limite=0;
$end =ceil($cantidad / $tamanoPagina) + 1;
for($begin=0; $begin < $end; $begin ++ )
{
echo"<a href='ResultadoMedicos.php?inicio=$limite&nom=$idmed&esp=$idesp&est=$idest&mun=$idmun&serv=$servi'>[$begin]</a> \n");
$limite=$limite + $tamanoPagina;
}
}
//FIN FUNCION
?>
<!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">
<!-- DW6 -->
<head>
<!-- Copyright 2005 Macromedia, Inc. All rights reserved. -->
<title>Directorio On-line</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<link rel="stylesheet" href="mm_restaurant1.css" type="text/css" />
<style type="text/css">
<!--
.Estilo1 {font-family: Verdana, Arial, Helvetica, sans-serif}
body {
margin-left: 190px;
margin-top: 80px;
margin-right: 2%;
margin-bottom: -33px;
background-image: url(imagenes/fondo.png);
}
.Estilo2 {
color: #660033;
font-weight: bold;
font-style: italic;
}
.Estilo5 {font-size: 16px}
.Estilo9 {font-size: 10}
-->
</style>
</head>
<body>
<table width="90%" height="579" border="0" align="center" cellpadding="0" cellspacing="0">
<tr bgcolor="#99ccff">
<td width="15" nowrap="nowrap" ><img src="mm_spacer.gif" alt="" width="15" height="1" border="0" /></td>
<td height="60" colspan="3" class="logo" nowrap="nowrap"><br />
DIRECTORIO ON-LINE <span class="tagline">| ENCUENTRAS LO QUE BUSCAS</span></td>
<td width="40"> </td>
<td width="100%"> </td>
</tr>
<tr bgcolor="#003399">
<td width="15" nowrap="nowrap"> </td>
<td height="36" colspan="3" id="navigation" nowrap="nowrap" class="navText"> <a href="index.html">INICIO</a> <a href="registro.php">INGRESE SUS DATOS AL DIRECTORIO </a> <a href="buscar.php">BUSQUEDA AVANZADA </a>
<a href="especialidades.php">ESPECIALIDADES</a></span> </td>
<td width="40"> </td>
<td width="100%"> </td>
</tr>
<tr bgcolor="#ffffff">
<td colspan="6"><img src="mm_spacer.gif" alt="" width="1" height="1" border="0" /></td>
</tr>
<tr bgcolor="#ffffff">
<td width="230" colspan="2" valign="top" bgcolor="#ffffcc"><img src="imagenes/medicos.jpg"...
<?
include('conexion.php');
if(isset($_POST['buscar']))
{ $a=$_POST['especialidad'];
$b=$_POST['estados'];
$c=$_POST['municipios'];
$d=strtoupper($_POST['servicios']);
$sql="select idmedico from medicos WHERE idespecialidad=$a AND idestado=$b AND idmunicipio=$c and servicios LIKE '%".$d."%'; ";
$rs =@mysql_query($sql,$link);
$cantReg=@mysql_num_rows($rs);
if($cantReg == 0)
{
echo('
<p> No se encontro ningun resultado </p>
');
}
else
{
echo('
<p>
<a href="ResultadoMedicos.php?esp='.$a.'&est='.$b.'&mun='.$c.'&serv='.$d.'" target="_self">HAY '.$cantReg.' RESULTADOS</a><img src="imagenes/resultados.png" width="25" height="25"/> </p>
');
}
}
?>
st es el archivo resultadomedicos.php
<?
$tamanoPagina=5;
if ( isset($_GET['inicio']))
{
$inicio=$_GET['inicio'];
}
else
{
$inicio=0;
}
include("conexion.php");
$link=Conectarse();
$idesp =$_GET['esp'];
$idest =$_GET['est'];
$idmun =$_GET['mun'];
$servi =$_GET['servicios'];
$sql="SELECT nombre, appaterno,apmaterno,cedulaprofesional,idespecialidad,servicios,calle,numero,colonia,idestado,idmunicipio,cp,horarioconsulta,telefono,celular,email FROM medicos
WHERE
medicos.idestado=".$idest." AND medicos.idmunicipio=".$idmun." AND medicos.idespecialidad=".$idesp." LIMIT $inicio,$tamanoPagina";
//echo($sql);
$sql = mysql_query($sql) or die(mysql_error());
$numReg=mysql_num_rows($sql);
//PAGINACION ARRIBA
creaPaginacion($numReg ,$tamanoPagina,$idest,$idmun,$idcat);
while($matriz=mysql_fetch_array($sql))
{
echo(" Nombre: <span class='Estilo1'><a href='DescripcionEmpresas.php?empr=".$matriz['idempresa']."' target='_blank'>".$matriz['nomempresa']."</a></span>
Vacantes: ");
//CODIGO PARA ADMNISTRAR LA PAGINACION DEL CATALOGO
$tamanoPagina=3;
if ( isset($_GET['inicio']))
{
$inicio=$_GET['inicio'];
}
else
{
$inicio=0;
}
//FIN
//UNA FUNCION PARA CREAR UNA PAGINACION OPCION UNO
function creaPaginacionUno($cantidad,$tamanoPagina,$idmed,$idesp,$idest,$idmun,$servi)
{
$limite=0;
$end =ceil($cantidad / $tamanoPagina) + 1;
for($begin=0; $begin < $end; $begin ++ )
{
echo("<a href='ResultadoMedicos.php?inicio=$limite&esp=$idesp&est=$idest&mun=$idmun&servicios=$servi'>[$begin]</a> \n");
$limite=$limite + $tamanoPagina;
}
}
//FIN FUNCION
//UNA FUNCION PARA CREAR UNA PAGINACION OPCION DOS
function creaPaginacionDos($cantidad,$tamanoPagina,$idmed,$idesp,$idest,$idmun,$servi)
{
$limite=0;
$end =ceil($cantidad / $tamanoPagina) + 1;
for($begin=0; $begin < $end; $begin ++ )
{
echo"<a href='ResultadoMedicos.php?inicio=$limite&nom=$idmed&esp=$idesp&est=$idest&mun=$idmun&serv=$servi'>[$begin]</a> \n");
$limite=$limite + $tamanoPagina;
}
}
//FIN FUNCION
?>
<!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">
<!-- DW6 -->
<head>
<!-- Copyright 2005 Macromedia, Inc. All rights reserved. -->
<title>Directorio On-line</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<link rel="stylesheet" href="mm_restaurant1.css" type="text/css" />
<style type="text/css">
<!--
.Estilo1 {font-family: Verdana, Arial, Helvetica, sans-serif}
body {
margin-left: 190px;
margin-top: 80px;
margin-right: 2%;
margin-bottom: -33px;
background-image: url(imagenes/fondo.png);
}
.Estilo2 {
color: #660033;
font-weight: bold;
font-style: italic;
}
.Estilo5 {font-size: 16px}
.Estilo9 {font-size: 10}
-->
</style>
</head>
<body>
<table width="90%" height="579" border="0" align="center" cellpadding="0" cellspacing="0">
<tr bgcolor="#99ccff">
<td width="15" nowrap="nowrap" ><img src="mm_spacer.gif" alt="" width="15" height="1" border="0" /></td>
<td height="60" colspan="3" class="logo" nowrap="nowrap"><br />
DIRECTORIO ON-LINE <span class="tagline">| ENCUENTRAS LO QUE BUSCAS</span></td>
<td width="40"> </td>
<td width="100%"> </td>
</tr>
<tr bgcolor="#003399">
<td width="15" nowrap="nowrap"> </td>
<td height="36" colspan="3" id="navigation" nowrap="nowrap" class="navText"> <a href="index.html">INICIO</a> <a href="registro.php">INGRESE SUS DATOS AL DIRECTORIO </a> <a href="buscar.php">BUSQUEDA AVANZADA </a>
<a href="especialidades.php">ESPECIALIDADES</a></span> </td>
<td width="40"> </td>
<td width="100%"> </td>
</tr>
<tr bgcolor="#ffffff">
<td colspan="6"><img src="mm_spacer.gif" alt="" width="1" height="1" border="0" /></td>
</tr>
<tr bgcolor="#ffffff">
<td width="230" colspan="2" valign="top" bgcolor="#ffffcc"><img src="imagenes/medicos.jpg"...
1 respuesta
Respuesta de Jorge Vila
1