
ARCHIVO NOMINA.PHP
Código PHP:
<html>
<head> <title> Reportes </title> </head>
<body>
<center>
<form enctype="multipart/form-data" action="busca.php" method="post">
<?php
echo'<b>Numero de Pension:</b>';
echo'<input type="text" name="pension" size="20" ';
echo'<br>';echo'<br>';
echo'<b>Año de consulta:</b>';
?>
<select name="anio">
<option value="">-Selecciona un año-</option>
<option value="2004">2004</option>
<option value="2005">2005</option>
<option value="2006">2006</option>
<option value="2007">2007</option>
<option value="2008">2008</option>
<option value="2009">2009</option> //en esta tabla no funciona
<option value="2010">2010</option> //en esta tabla no funciona
<option value="2011">2011</option>
</select>
<br><br>
<input type="submit" value="Buscar">
</form></center></body></html>
Como dato curioso, las tabla 2009 y 2010 son las mas grandes: 8,197,086 y 9,051,565 registros. A comparacion de 2008 que tiene 7,436,472 registros.
Código PHP:
if($anio==2011)
{
$nom11=mssql_query("select [numero usuario] as clave,
[clave del registro federal del causante] as rfc,
[nombre del trabajador] as nombre,
CEILING ([Clave de Cobro del Trabajador]) as pension,
[fecha de movimiento desde] as fecha,
[descuento por prestamos personales] as descuento
from nomina11
where [clave de cobro del trabajador]= $pen
order by FECHA asc",$conn);
echo'<table width="90%" border="1">';
echo'<tr>';
echo'<th width="15%"><b> CLAVE </b></th>';
echo'<th width="15%"><b> RFC </b></th>';
echo'<th width="30%"><b> NOMBRE </b></th>';
echo'<th width="15%"><b> PENSION </b></th>';
echo'<th width="10%"><b> FECHA </b></th>';
echo'<th width="15%"><b> DESCUENTO </b></th>';
echo'</tr>';
while ($row=mssql_fetch_array($nom11)){
echo'<tr align="center" valign="middle">';
echo'<td>';
echo''.$row["clave"].'';
echo'</td>';
echo'<td>';
echo''.$row["rfc"].'';
echo'</td>';
echo'<td>';
echo''.$row["nombre"].'';
echo'</td>';
echo'<td>';
echo''.$row["pension"].'';
echo'</td>';
echo'<td>';
echo''.$row["fecha"].'';
echo'</td>';
echo'<td>';
echo''.$row["descuento"].'';
echo'</td>';
echo'</tr>';}
mssql_free_result($nom11);
echo'</table>';
}
elseif($anio==2010)
{
$nom10=mssql_query("select [numero usuario] as clave,
[clave del registro federal del causante] as rfc,
[nombre del trabajador] as nombre,
CEILING ([Clave de Cobro del Trabajador]) as pension,
[fecha de movimiento desde] as fecha,
[descuento por prestamos personales] as descuento
from nomina10
where CEILING([clave de cobro del trabajador])= $pen
order by FECHA asc",$conn); //AQUI ES 1ER WARNING
echo'<table width="90%" border="1">';
echo'<tr>';
echo'<th width="15%"><b> CLAVE </b></th>';
echo'<th width="15%"><b> RFC </b></th>';
echo'<th width="30%"><b> NOMBRE </b></th>';
echo'<th width="15%"><b> PENSION </b></th>';
echo'<th width="10%"><b> FECHA </b></th>';
echo'<th width="15%"><b> DESCUENTO </b></th>';
echo'</tr>';
while ($row = mssql_fetch_array($nom10)){ //AQUI ES 2DO WARNING
echo'<tr align="center" valign="middle">';
echo'<td>';
echo''.$row["clave"].'';
echo'</td>';
echo'<td>';
echo''.$row["rfc"].'';
echo'</td>';
echo'<td>';
echo''.$row["nombre"].'';
echo'</td>';
echo'<td>';
echo''.$row["pension"].'';
echo'</td>';
echo'<td>';
echo''.$row["fecha"].'';
echo'</td>';
echo'<td>';
echo''.$row["descuento"].'';
echo'</td>';
echo'</tr>';}
mssql_free_result($nom10); //AQUI ES 3ER WARNING
echo'</table>';
}
Warning: mssql_query() [function.mssql-query]: Query failed in C:\AppServ\www\busca.php on line 70
Warning: mssql_fetch_array(): supplied argument is not a valid MS SQL-result resource in C:\AppServ\www\busca.php on line 81
Warning: mssql_free_result(): supplied argument is not a valid MS SQL-result resource in C:\AppServ\www\busca.php on line 102
Alguna idea de donde esta el error ???
Gracias de antemano
www.pittmx.com