tengo u ncodigo php que me permite hacer una busqueda de usuarios por so codigo de trabajor (0001, 0002,0003...) y bueno le crre un indice y pusecomo ind-personsl s enla tabla y los id_tipo 5 ya que todos me interesan. Lo que sucedee s que al querer consultar uno por uno, por ejm por 0001, me salen todos.
Luego quise probar una cosa: puse 0000 y salio lo mismo, todos.
Entonces me puse a pensar que pasa o que puse mal o que me falta.
Pido ayuda a uds., maestros.
Espero me respondan.
M i codigo php es el siguiente de mi pag_consulta
Código PHP:
<?
session_start();
include("include/bd.php");
include("include/functions.php");
bd_connect();
if(isset($_GET['Buscar'])) {
if(isset($_GET['paterno']) and $_GET['paterno'] != '') {
$sql_more .= " AND paterno LIKE '%" . $_GET['paterno'] . "%' ";
}
if(isset($_GET['materno']) and $_GET['materno'] != '') {
$sql_more .= " AND materno LIKE '%" . $_GET['materno'] . "%' ";
}
if(isset($_GET['nombre']) and $_GET['nombre'] != '') {
$sql_more .= " AND nombre LIKE '%" . $_GET['nombre'] . "%' ";
}
$personal = "SELECT id_per, paterno, materno, nombre, id_ope, direccion_ope
FROM personal WHERE ind_personal = 'S'
AND id_tipo = '5' ";
//echo $personal;
$personal_query = db_query($personal);
}
?>
<html>
<head>
<title>Registro</title>
<h1 align="center">Horario de Registro de Personal</h1>
<script language="JavaScript" type="text/javascript">
function validaBusq() {
if(document.frmPersonal.codigo.value == "" ) {
alert("Debe ingresar su codigo");
document.frmPersonal.codigo.focus();
return false;
}
return true;
}</script>
<script src="http://www.clocklink.com/embed.js"></script><script type="text/javascript" language="JavaScript">obj=new Object;obj.clockfile="5005-gray.swf";obj.TimeZone="Peru_Lima";obj.width=120;obj.height=40;obj.wmode="transparent";showClock(obj);</script>
</head>
</script>
</head>
<body>
<!--<form name="frmPersonal" method="get" action="contenido2.php" target="fraBusPersonal" onsubmit="return validaBusqw();">-->
<form name="frmPersonal" method="get" action="/registros/contenido_result.php" onSubmit="return validaBusq();">
<table border="0" width="774" height="458" cellpadding="0" cellspacing="0">
<tr>
<td valign="top">
<table border="0" width="600" cellpadding="0" cellspacing="0" align="center">
<tr>
<td align="center"><p class="clsLblTituloPagina">Ingreso</p></td>
</tr>
<tr>
<td><hr></td>
</tr>
</table><br>
<table border="0" width="600" cellpadding="0" cellspacing="0" align="center">
<tr>
<td>Código:</td>
<td><input type="text" name="codigo" value="" class="clsText" onBlur="javascript:this.value=this.value.toUpperCase();"></td>
</tr>
</table>
<br>
<table border="0" width="600" cellpadding="0" cellspacing="0" align="center">
<tr>
<td align="center">
<input type="submit" name="Buscar" value="Buscar" class="clsSubmit">
</td>
</tr>
</table>
<br>
<table width="650" height="330" border="0" cellspacing="0" cellpadding="0" align="center">
<tr>
<td>
<!--<iframe name="fraBusPersonal" marginwidth=0 marginheight=0
src="pagina_blanco.php" frameborder=1
width=100% scrolling=no height="170"></iframe>-->
</td>
</tr>
</table>
</td>
</tr>
</table>
<input type="hidden" name="IDreg" value="">
</form>
<?include("pie.php");?>
</body>
</html>
Código PHP:
<?
session_start();
include("include/bd.php");
include("include/functions.php");
bd_connect();
if(isset($_GET['paterno']) and $_GET['paterno'] != '') {
$sql_more .= " AND paterno LIKE '%" . $_GET['paterno'] . "%' ";
}
if(isset($_GET['materno']) and $_GET['materno'] != '') {
$sql_more .= " AND materno LIKE '%" . $_GET['materno'] . "%' ";
}
if(isset($_GET['nombre']) and $_GET['nombre'] != '') {
$sql_more .= " AND nombre LIKE '%" . $_GET['nombre'] . "%' ";
}
$personal= "SELECT id_per, paterno, materno, nombre, id_ope, direccion_ope
FROM personal WHERE id_tipo = '5'
" . $sql_more . "
ORDER BY id_per";
//echo $personal;
$personal_query = db_query($personal);
?>
<html>
<head>
<title>REGISTRO</title>
</head>
<body>
<div style="height:280;width:100%;overflow:auto">
<table border="0" width="100%" cellpadding="0" cellspacing="0">
<tr>
<td valign="top">
<table border="0" width="100%" cellpadding="0" cellspacing="0" align="center">
<tr>
<td class="clsTituloTabla" align="center" width="30">Nro.</td>
<td class="clsTituloTabla">Código</td>
<td align="center" class="clsTituloTabla">Nombres</td>
<td align="center" class="clsTituloTabla">id_ope</td>
<td align="center" class="clsTituloTabla">Oficina de Enlace</td>
<td align="center" class="clsTituloTabla"> </td>
</tr>
<?
$i = 1;
while($personal = db_fetch_array($personal_query)) {
?>
<tr onMouseOver="this.className='dataTableRowSelected'" onmouseout="this.className='dataTableRow'">
<td align="center" height="22"><?echo $i?></td>
<td><?echo $personal['id_per']?></td>
<td align="center"><?echo $personal['paterno'] . ' ' . $personal['materno'] . ' ' . $personal['nombre']?></td>
<td align="center"><?echo $personal['id_ope']?></td>
<td align="center"><?echo $personal['direccion_ope']?></td>
</tr>
<tr>
<td colspan="7" height="1" bgcolor="#000000"></td>
</tr>
<?
$i++;
}
?>
</table>
<?
$Fecha= date('d-m-Y',time() - 21600 ); //le sumé horas
$Hora= date('H:i:s',time() ); //le sumé una hora
echo "Fecha: ".$Fecha;
echo "<br>";
echo "Su hora de ingreso ha sido: ".$Hora;
echo "<br>";
?>
<?
if ($Hora >= date ('-20:10:00',time()+18000)){
echo "UD. LLEGO TARDE";
}
else{
echo "UD. LLEGO TEMPRANO";
}
?>
</td>
</tr>
</table>
</div>
</body>
</html>