hola gracias por si ayuda generosa
Mi consulta viene a ser la sgte:
deseo hacer una busqueda por varios campos pero no quiero llenar todos sino que con uno solo me de como resultado las coincidencias que encuentre. Me resulta bien con codigo, pero los demas no ¿que esta mal?
Código PHP:
<?
session_start();
include("include/bd.php");
include("include/functions.php");
$cod=$_GET['codigo'];
bd_connect();
if(!isset($_SESSION['user'])) {
header("Location: index.php");
}
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'] . "%' ";
}
$reporte = "SELECT id_per, CONCAT(paterno, ' ', materno, ' ', nombre) as nom, direccion_ope, cargo
FROM reporte WHERE id_per= '$cod'
" . $sql_more . "
ORDER BY paterno";
//echo $reporte;
$reporte_query = db_query($reporte);
}
?>
<html>
<head>
<title>OSAED</title>
<link rel="stylesheet" href="include/estilos.css" type="text/css">
<script language="JavaScript" src ="include/common.js"> </script>
<script language="JavaScript" type="text/javascript">
function validaBusq() {
if(document.frmPersonal.codigo.value == "" && document.frmPersonal.paterno.value == "" &&
document.frmPersonal.materno.value == "" && document.frmPersonal.nombre.value == "") {
alert("Debe ingresar una referencia de búsqueda");
document.frmPersonal.paterno.focus();
return false;
}
return true;
}
</script>
</head>
<body>
<?include("cabecera.php");?>
<br>
<!--<form name="frmPersonal" method="get" action="personal_result.php" target="fraBusPersonal" onsubmit="return validaBusqw();">-->
<form name="frmPersonal" method="get" action="<?echo $_SERVER['PHP_SELF']?>" onSubmit="return validaBusq();">
<table border="0" width="550" cellpadding="0" cellspacing="0" align="center">
<tr>
<td valign="top">
<table border="0" width="550" cellpadding="0" cellspacing="0" align="center">
<tr>
<td align="center"><p class="clsLblTituloPagina">Búsqueda </p></td>
</tr>
<tr>
<td><hr></td>
</tr>
</table><br>
<table border="0" width="550" cellpadding="0" cellspacing="0" align="center">
<tr>
<td>Código:</td>
<td><input type="text" name="codigo" value="<?echo $_GET['id_per']?>" class="clsText" onBlur="javascript:this.value=this.value.toUpperCase();"></td>
<td>Ap. Paterno:</td>
<td><input type="text" name="paterno" value="<?echo $_GET['paterno']?>" class="clsText" onBlur="javascript:this.value=this.value.toUpperCase();"></td>
<td>Ap. Materno:</td>
<td><input type="text" name="materno" value="<?echo $_GET['materno']?>" class="clsText" onBlur="javascript:this.value=this.value.toUpperCase();"></td>
</tr>
<tr>
<td>Nombres:</td>
<td><input type="text" name="nombre" value="<?echo $_GET['nombre']?>" class="clsText" onBlur="javascript:this.value=this.value.toUpperCase();"></td>
<td>Dirección:</td>
<td><input type="text" name="direccion" value="<?echo $_GET['direccion_ope']?>" class="clsText" onBlur="javascript:this.value=this.value.toUpperCase();"></td>
<td> </td>
<td> </td>
</tr>
</table>
<br>
<table border="0" width="550" 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="550" 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>-->
<?if(isset($_GET['Buscar'])) {?>
<div style="height:181;width:100%;overflow:auto">
<table border="0" width="100%" cellpadding="0" cellspacing="0">
<tr>
<td valign="top">
<table border="0" width="750" cellpadding="0" cellspacing="0" align="center">
<tr>
<td class="clsTituloTabla" align="center" width="30">Nro.</td>
<td align="center" class="clsTituloTabla">Nombres</td>
<td class="clsTituloTabla">OPE</td>
<td ALIGN= "CENTER" class="clsTituloTabla">Cargo</td>
<td class="clsTituloTabla"> </td>
</tr>
<?
$i = 1;
while($reporte = db_fetch_array($reporte_query)) {
?>
<tr onMouseOver="this.className='dataTableRowSelected'" onMouseOut="this.className='dataTableRow'">
<td align="center" height="22"><?echo $i?></td>
<td align="center"> <?echo $reporte['nom']?></td>
<td align="left"><?echo $reporte['direccion_ope']?></td>
<td align="right"><?echo $reporte['cargo']?></td>
<td><a href="editar_personal.php?IDreg=<?echo $_GET['IDreg']?>&IDper=<?echo $reporte['id_per']?>&NOMper=<?echo $reporte['nom']?>"><img border="0" src="images/edit.gif" style="cursor: hand"> Editar</a></td>
</tr>
<tr>
<td colspan="15" height="1" bgcolor="#000000"></td>
</tr>
<?
$i++;
}
?>
</table>
</td>
</tr>
</table>
</div>
<?}?>
</td>
</tr>
</table>
</td>
</tr>
</table>
<input type="hidden" name="IDreg" value="<?echo $_GET['IDreg']?>">
</form>
</body>