Ver Mensaje Individual
  #1 (permalink)  
Antiguo 06/08/2008, 08:13
artrax57
 
Fecha de Ingreso: febrero-2007
Mensajes: 18
Antigüedad: 17 años, 3 meses
Puntos: 0
Ayuda con while

Hola:

Estoy trabajando con una tabla que muestra los resultados de una página de búsqueda y de manera general la tabla generada se despliega bien, pero no muestra los resultados completos, por ejemplo si la búsqueda debería arrojar 13 resultados solo aparecen 12, me parece que el error esta en la siguiente linea:

while($row_reportes=mysql_fetch_assoc($reportes)){

De cualquier forma, aqui dejo el código el cual gran parte ha sido generado en dreamweaver.

De antemano agradezco cualquier ayuda.

<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;

$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}

if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;

$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}


$diavar_reportes = "-1";
if (isset($_GET['dia'])) {
$diavar_reportes = $_GET['dia'];
}
$idmodulovar_reportes = "-1";
if (isset($_GET['idmodulo'])) {
$idmodulovar_reportes = $_GET['idmodulo'];
}
$ciclovar_reportes = "-1";
if (isset($_GET['idciclo'])) {
$ciclovar_reportes = $_GET['idciclo'];
}
$idmaestrovar_reportes = "-1";
if (isset($_GET['idmaestro'])) {
$idmaestrovar_reportes = $_GET['idmaestro'];
}
$anovar_reportes = "-1";
if (isset($_GET['ano'])) {
$anovar_reportes = $_GET['ano'];
}
$mesvar_reportes = "-1";
if (isset($_GET['mes'])) {
$mesvar_reportes = $_GET['mes'];
}
mysql_select_db($database_uceh, $uceh);
$query_reportes = sprintf("SELECT * FROM reportes r, alumnos a, maestros m, ciclos c, modulos mo, materias ma, anoescolar an WHERE r.dia = %s AND r.mes=%s AND r.ano=%s AND r.idmaestro=%s AND r.idciclo=%s AND r.idmodulo=%s AND r.idmodulo=mo.idmodulo AND r.matricula=a.matricula AND r.idmaestro=m.idmaestro AND r.idciclo=c.idciclo AND r.materia=ma.idmateria AND r.idanoescolar=an.idanoescolar ORDER BY a.nombre", GetSQLValueString($diavar_reportes, "text"),GetSQLValueString($mesvar_reportes, "text"),GetSQLValueString($anovar_reportes, "text"),GetSQLValueString($idmaestrovar_report es, "text"),GetSQLValueString($ciclovar_reportes, "text"),GetSQLValueString($idmodulovar_reporte s, "text"));
$reportes = mysql_query($query_reportes, $uceh) or die(mysql_error());
$row_reportes = mysql_fetch_assoc($reportes);
$totalRows_reportes = mysql_num_rows($reportes);
?><!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">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />

<title>panel</title>

<style type="text/css">
<!--
.style1 { font-family: Arial, Helvetica, sans-serif;
font-size: 14px;
color: #AC2326;
font-weight: bold;
}
.style2 { font-family: Arial, Helvetica, sans-serif;
color: #AC2326;
font-weight: bold;
}
-->
</style>




<style type="text/css">
<!--
.style1 { font-family: Arial, Helvetica, sans-serif;
font-size: 14px;
color: #AC2326;
font-weight: bold;
}
.style2 { font-family: Arial, Helvetica, sans-serif;
color: #AC2326;
font-weight: bold;
}
-->
</style>

<link href="../css.css" rel="stylesheet" type="text/css" />


<link href="../css.css" rel="stylesheet" type="text/css" />
</head>

<body bgcolor="#AF1E21">
<form id="form1" name="form1" method="post" action="okreportedia.php">
<p class="textomedio">&nbsp;</p>
<table border="1" cellpadding="3" cellspacing="0">
<tr class="fondoamarillooscuro">
<td>ID</td>
<td>alumno</td>
<td>matricula</td>
</tr>
<?
// Fetch record rows in $result by while loop and put them into $row.

while($row_reportes=mysql_fetch_assoc($reportes)){
?>
<tr class="textomedio">
<td><? echo $row_reportes['idreportes']; // Show record's ID ?>
<input name="reportado_<? echo $row_reportes['idreportes']; ?>" type="hidden" id="reportado_<? echo $row_reportes['idreportes']; ?>" value="si" /></td>
<td class="textomedio"><?php echo $row_reportes['nombre']; ?></td>
<td class="textomedio"><?php echo $row_reportes['matricula']; ?></td>
</tr>
<? } // End while loop. ?>
</table>
<input type="submit" name="Submit" value="Update" />
</form>
</body>
</html>
<?php
mysql_free_result($reportes);

?>