File: /home/asjudine/subdomains/correosasjudinet/httpdocs/buscador/paginador.php
<?php
include("../bd.php");
global $dbi;
$currentPage = $_SERVER["PHP_SELF"];
$maxRows_Rs = 25;// este numero es el numero de resultados que quieren que se vean por pagina pueden poner algo asi: $maxRows_Rs = 6; para ver paginas con 6 resultados
$pageNum_Rs = 0;
if (isset($_GET['pageNum_Rs']))
{
$pageNum_Rs = $_GET['pageNum_Rs'];
}
$startRow_Rs = $pageNum_Rs * $maxRows_Rs;
mysql_select_db($bd_bdname,$dbi);
$query_Rs = "SELECT * FROM correos ORDER BY id DESC"; // SELECT Anterior
if($_GET['id']) // Si existe la variable "id" en la barra url...
{
$id = $_GET['id'];
$query_Rs = "select * from correos where id = '$id' order by id desc";
}
//*BUSCADOR DE REGISTROS!*/
if ($_GET['buscar'])
{
$buscar = $_GET['buscar'];
$query_Rs ="SELECT * FROM correos WHERE cedula LIKE \"%$buscar%\" OR
apellidos LIKE \"%$buscar%\" OR
nombres LIKE \"%$buscar%\" OR
email LIKE \"%$buscar%\" OR
contrasena LIKE \"%$buscar%\" OR
email_alterno LIKE \"%$buscar%\" OR
direccion LIKE \"%$buscar%\" OR
ciudad LIKE \"%$buscar%\" OR
telefono LIKE \"%$buscar%\" OR
celular LIKE \"%$buscar%\" OR
tipo_afiliado LIKE \"$buscar%\" OR
numero_contrato LIKE \"$buscar%\" OR
tipo LIKE \"$buscar%\" ORDER BY id DESC";
}
$query_limit_Rs = sprintf("%s LIMIT %d, %d", $query_Rs, $startRow_Rs, $maxRows_Rs);
$Rs = mysql_query($query_limit_Rs, $dbi) or die(mysql_error());
if($Rs)
{
if ((mysql_num_rows($Rs)!=0))
{
$row_Rs = mysql_fetch_assoc($Rs);
if (isset($_GET['totalRows_Rs']))
{
$totalRows_Rs = $_GET['totalRows_Rs'];
}
else
{
$all_Rs = mysql_query($query_Rs);
$totalRows_Rs = mysql_num_rows($all_Rs);
}
$totalPages_Rs = ceil($totalRows_Rs/$maxRows_Rs)-1;
$queryString_Rs = "";
if (!empty($_SERVER['QUERY_STRING']))
{
$params = explode("&", $_SERVER['QUERY_STRING']);
$newParams = array();
foreach ($params as $param)
{
if (stristr($param, "pageNum_Rs") == false && stristr($param, "totalRows_Rs") == false)
{
array_push($newParams, $param);
}
}
if (count($newParams) != 0)
{
$queryString_Rs = "&" . htmlentities(implode("&", $newParams));
}
}
$queryString_Rs = sprintf("&totalRows_Rs=%d%s", $totalRows_Rs, $queryString_Rs);
}
else
{
echo "<script>alert('El dato ingresado no existe en la base de datos.');</script>";
}
}
?>
<html>
<head>
<title>Buscador múltiple de datos - Serviasjudinet</title>
<link href="css/hoja-de-estilo.css" rel="stylesheet" type="text/css">
<style type="text/css">
<!--
.Estilo98 {color: #333333}
-->
</style>
</head>
<body>
<table width="1600" border="1" cellspacing="0" cellpadding="0">
<tr>
<td colspan="3"><span class="Estilo10"><img src="images/icn_arrow.gif" width="6" height="6"> <span class="titulo-naranja"><strong>BUSCADOR MULTIPLE DE DATOS (Sólo escriba el datos a buscar ) </strong></span></span></td>
</tr>
<tr>
<td width="156" height="20" bgcolor="#CCCCCC" class= "label"><div align="left" >Escriba el datos a Buscar:</div></td>
<td width="242" class= "label"> <table width="242" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="242" bgcolor="#ECE9D8"><?php include "includes/buscador.php"; ?></td>
</tr>
</table></td>
<td width="1194" bgcolor="#CCCCCC" class= "label">puede ser por cédula, apellidos, nombres, email, email alterno.. todos los campos.</td>
</tr>
</table>
<table width="770" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td width="609" valign="top"><table width="580" border="0" align="right" cellpadding="0" cellspacing="0">
<tr>
<td>
<TABLE width="1700" border="1" align="center" cellpadding="0" cellspacing="1">
<TR>
<TD bgcolor="#FFFFCC"><div align='center'><span class="label">ID</span></TD>
<TD bgcolor="#FFFFCC"><div align='center'><span class="label">CONSE</span></TD>
<TD bgcolor="#FFFFCC"><div align='center'><span class="label">ESTADO</span></TD>
<TD bgcolor="#FFFFCC"><div align='center'><span class="label">CEDULA</span></TD>
<TD bgcolor="#FFFFCC"><div align='center'><span class="label">APELLIDOS - NOMBRES</span></TD>
<TD bgcolor="#FFFFCC"><div align='center'><span class="label">EMAIL</span></TD>
<TD bgcolor="#FFFFCC"><div align='center'><span class="label">CONTRASEÑA</span></TD>
<TD bgcolor="#FFFFCC"><div align='center'><span class="label">EMAIL ALTERNO</span></TD>
<TD bgcolor="#FFFFCC"><div align='center'><span class="label">DIRECCION POSTAL</span></TD>
<TD bgcolor="#FFFFCC"><div align='center'><span class="label">CIUDAD</span></TD>
<TD bgcolor="#FFFFCC"><div align='center'><span class="label">TELEFONO FIJO</span></TD>
<TD bgcolor="#FFFFCC"><div align='center'><span class="label">CELULAR</span></TD>
<TD bgcolor="#FFFFCC"><div align='center'><span class="label">DIA NACIMIENTO</span></TD>
<TD bgcolor="#FFFFCC"><div align='center'><span class="label">MES NACIMIENTO</span></TD>
<TD bgcolor="#FFFFCC"><div align='center'><span class="label">ENTIDAD LABORAL</span></TD>
<TD bgcolor="#FFFFCC"><div align='center'><span class="label">TIPO DE AFILIADO</span></TD>
<TD bgcolor="#FFFFCC"><div align='center'><span class="label">CONTRATO</span></TD>
<TD bgcolor="#FFFFCC"><div align='center'><span class="label">TIPO</span></TD>
</TR>
<?php
$conta = 1;
do
{
$estado = $row_Rs['estado'];
if($estado == '1')
{
?>
<tr bgcolor="#00CCFF">
<td class="texto-chico"><div align="left" class="texto-comun"><?php echo "<a href=\"../mostrar_datos.php?id=".$row_Rs['id']."\">".$row_Rs['id']."</a>"; ?></div></td>
<td class="texto-chico"><div align="left" class="texto-comun"><?php echo $startRow_Rs+1; ?></td>
<td class="texto-chico"><div align="left" class="texto-comun"><?php echo "<div align='center' class='text-bordo'>creado</div>"; ?></div></td>
<td class="texto-chico"><div align="left" class="texto-comun"><?php echo $row_Rs['cedula']; ?></div></td>
<td class="texto-chico"><div align="left" class="texto-comun"><?php echo $row_Rs['apellidos']."-".$row_Rs['nombres']; ?></div></td>
<td class="fecha-texto"><div align="left" class="texto-comun"><?php echo $row_Rs['email']; ?></div></td>
<td class="fecha-texto"><div align="left" class="texto-comun"><?php echo $row_Rs['contrasena']; ?></div></td>
<td class="fecha-texto"><div align="left" class="texto-comun"><?php echo $row_Rs['email_alterno']; ?></div></td>
<td class="fecha-texto"><div align="left" class="texto-comun"><?php echo $row_Rs['direccion']; ?></div></td>
<td class="fecha-texto"><div align="left" class="texto-comun"><?php echo $row_Rs['ciudad']; ?></div></td>
<td class="fecha-texto"><div align="left" class="texto-comun"><?php echo $row_Rs['telefono']; ?></div></td>
<td class="fecha-texto"><div align="left" class="texto-comun"><?php echo $row_Rs['celular']; ?></div></td>
<td class="fecha-texto"><div align="left" class="texto-comun"><?php echo $row_Rs['dia_nacimiento']; ?></div></td>
<td class="fecha-texto"><div align="left" class="texto-comun"><?php echo $row_Rs['mes_nacimiento']; ?></div></td>
<?
//traer nombre de la entidad laboral
$codigo = $row_Rs['entidad_laboral'];
$dep = mysql_query("select * from empresas where codigo = $codigo",$dbi);
if($dep)
{
list($nombre_entidad) = mysql_fetch_array($dep);
}
?>
<td class="fecha-texto"><div align="left" class="texto-comun"><?php echo $nombre_entidad; ?></div></td>
<td class="fecha-texto"><div align="left" class="texto-comun"><?php echo $row_Rs['tipo_afiliado']; ?></div></td>
<td class="fecha-texto"><div align="left" class="texto-comun"><?php echo $row_Rs['numero_contrato']; ?></div></td>
<td class="fecha-texto"><div align="left" class="texto-comun"><?php echo $row_Rs['tipo']; ?></div></td>
</tr>
<?php
}
else
{
?>
<tr bgcolor="#00CCFF">
<td class="texto-chico"><div align="left" class="texto-comun"><?php echo "<a href=\"../mostrar_datos.php?id=".$row_Rs['id']."\">".$row_Rs['id']."</a>"; ?></div></td>
<td class="texto-chico"><div align="left" class="texto-comun"><?php echo $startRow_Rs+1; ?></td>
<td class="texto-chico"><div align="left" class="texto-comun"><?php echo "<div align='center' class='text-azul'>sin crear</div>"; ?></div></td>
<td class="texto-chico"><div align="left" class="texto-comun"><?php echo $row_Rs['cedula']; ?></div></td>
<td class="texto-chico"><div align="left" class="texto-comun"><?php echo $row_Rs['apellidos']."-".$row_Rs['nombres']; ?></div></td>
<td class="fecha-texto"><div align="left" class="texto-comun"><?php echo $row_Rs['email']; ?></div></td>
<td class="fecha-texto"><div align="left" class="texto-comun"><?php echo $row_Rs['contrasena']; ?></div></td>
<td class="fecha-texto"><div align="left" class="texto-comun"><?php echo $row_Rs['email_alterno']; ?></div></td>
<td class="fecha-texto"><div align="left" class="texto-comun"><?php echo $row_Rs['direccion']; ?></div></td>
<td class="fecha-texto"><div align="left" class="texto-comun"><?php echo $row_Rs['ciudad']; ?></div></td>
<td class="fecha-texto"><div align="left" class="texto-comun"><?php echo $row_Rs['telefono']; ?></div></td>
<td class="fecha-texto"><div align="left" class="texto-comun"><?php echo $row_Rs['celular']; ?></div></td>
<td class="fecha-texto"><div align="left" class="texto-comun"><?php echo $row_Rs['dia_nacimiento']; ?></div></td>
<td class="fecha-texto"><div align="left" class="texto-comun"><?php echo $row_Rs['mes_nacimiento']; ?></div></td>
<?
//traer nombre de la entidad laboral
$codigo = $row_Rs['entidad_laboral'];
$dep = mysql_query("select * from empresas where codigo = $codigo",$dbi);
if($dep)
{
list($nombre_entidad) = mysql_fetch_array($dep);
}
?>
<td class="fecha-texto"><div align="left" class="texto-comun"><?php echo $nombre_entidad; ?></div></td>
<td class="fecha-texto"><div align="left" class="texto-comun"><?php echo $row_Rs['tipo_afiliado']; ?></div></td>
<td class="fecha-texto"><div align="left" class="texto-comun"><?php echo $row_Rs['numero_contrato']; ?></div></td>
<td class="fecha-texto"><div align="left" class="texto-comun"><?php echo $row_Rs['tipo']; ?></div></td>
</tr>
<?php
}
$startRow_Rs = $startRow_Rs + 1;
}
while ($row_Rs = mysql_fetch_assoc($Rs));
if ($colorfila==0){
$color= "#DEDEBE";
$colorfila=1;
}else{
$color="#F0F0F0";
$colorfila=0;
}
?>
</table></td>
</tr>
<tr>
<td><table width="1600" border="0" cellspacing="0" cellpadding="0">
<tr>
<td height="16"><img src="images/wna_linea_horiz.gif" width="1600" height="8"></td>
</tr>
<tr>
<td height="10"><table width="700" height="34" border="0" align="center" cellpadding="0" cellspacing="0">
<tr bgcolor="#FBFBFB">
<td width="65" class="texto-chico"><div align="center">
<?php if ($pageNum_Rs > 0) { // Show if not first page ?>
<a href="<?php printf("%s?pageNum_Rs=%d%s", $currentPage, 0, $queryString_Rs); ?>" class="txt-paginador"><strong>Primero</strong></a>
<?php } // Show if not first page ?>
</div></td>
<td width="80" class="texto-chico"><div align="center">
<?php if ($pageNum_Rs > 0) { // Show if not first page ?>
<a href="<?php printf("%s?pageNum_Rs=%d%s", $currentPage, max(0, $pageNum_Rs - 1), $queryString_Rs); ?>" class="txt-paginador"><strong> < Anterior</strong></a>
<?php } // Show if not first page ?>
</div></td>
<td width="312"><div align="center" class="titCategoria"><strong>
<?php $last=$totalPages_Rs+1;$current=$pageNum_Rs+1;for ($i = 1; $i <= $last; $i++) {if($current==$i){ echo $i." ."; }else{?>
<a href="<?php printf("%s?pageNum_Rs=%d%s", $currentPage, min($totalPages_Rs, $i-1), $queryString_Rs); ?>"><? echo $i;?></a>
<?
}
}
?>
</strong></div></td>
<td width="77"><div align="right" class="txt-paginador">
<?php if ($pageNum_Rs < $totalPages_Rs) { // Show if not last page ?>
<div align="center"><a href="<?php printf("%s?pageNum_Rs=%d%s", $currentPage, min($totalPages_Rs, $pageNum_Rs + 1), $queryString_Rs); ?>" class="txt-paginador"><strong>Siguiente > </strong></a> </div>
<?php } // Show if not last page ?>
</div></td>
<td width="56"><div align="right">
<?php if ($pageNum_Rs < $totalPages_Rs) { // Show if not last page ?>
<div align="center" class="txt-paginador"><span class="titCategoria"><a href="<?php printf("%s?pageNum_Rs=%d%s", $currentPage, $totalPages_Rs, $queryString_Rs); ?>" class="txt-paginador"><strong>Ultimo</strong></a></span> </div>
<?php } // Show if not last page ?>
</div></td>
</tr>
</table>
<div align="left"></div>
<table width="590" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td height="26"><div align="right" class="text-marroncito">
<div align="center"><strong>Está en la Página:
<?
if($totalPages_Rs==0){
echo "0/0";
}else{
echo $pageNum_Rs+1;
echo "/";
echo $totalPages_Rs+1;
}
?>
</strong></div>
</div></td>
</tr>
</table></td>
</tr>
</table></td>
</tr>
</table></td>
<td height="24"></tr>
</table>
<p align="center" class="texto-comun">asjudinet ltda</span></p>
</body>
</html>
<?php
mysql_free_result($Rs);
?>