Código HTML:
<?php require_once('Connections/miconexion.php'); ?><?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; } } $colname_nombres = "-1"; if (isset($_POST['curso'])) { $colname_nombres = $_POST['curso']; } mysql_select_db($database_miconexion, $miconexion); $query_nombres = sprintf("SELECT mmateria, mcurso FROM materia WHERE mcurso = %s ORDER BY mmateria ASC", GetSQLValueString($colname_nombres, "text")); $nombres = mysql_query($query_nombres, $miconexion) or die(mysql_error()); $row_nombres = mysql_fetch_assoc($nombres); $totalRows_nombres = mysql_num_rows($nombres); $colname_abril = "-1"; if (isset($_POST['estudiante'])) { $colname_abril = $_POST['estudiante']; } $mes_abril = "-1"; if (isset($_POST['m1'])) { $mes_abril = $_POST['m1']; } mysql_select_db($database_miconexion, $miconexion); $query_abril = sprintf("SELECT codigo, est, ac, td, tg, la, `as`, punt, uni, comp FROM nota WHERE codigo LIKE %s and codigo LIKE %s", GetSQLValueString("%" . $colname_abril . "%", "text"),GetSQLValueString("%" . $mes_abril . "%", "text")); $abril = mysql_query($query_abril, $miconexion) or die(mysql_error()); $row_abril = mysql_fetch_assoc($abril); $totalRows_abril = mysql_num_rows($abril); ?> <body> <table border="0" cellpadding="0" cellspacing="0"> <tr> <td>mmateria</td> <td>mcurso</td> </tr> <?php do { ?> <tr> <td><?php echo $row_nombres['mmateria']; ?></td> <td><table border="0" cellpadding="0" cellspacing="0"> <tr> </tr> <? reset($abril); do { ?> <tr> <td><?php echo $row_abril['codigo']; ?></td> <td> </td> <td><?php echo $row_abril['ac']+$row_abril['td']+ $row_abril['tg']+ $row_abril['la']; echo "-"; echo $row_abril['as']+$row_abril['punt']+$row_abril['uni']+$row_abril['comp']; ?></td> </tr> <?php } while ($row_abril = mysql_fetch_assoc($abril)); ?> </table></td> </tr> <?php } while ($row_nombres = mysql_fetch_assoc($nombres)); ?> </table> </body> </html> <?php mysql_free_result($nombres); mysql_free_result($abril); ?>