mi intención es hacer una apliación sencilla para que estudiantes puedan ver sus calificaciones vía internet. La aplicación sin diseño ya quedo, lo que muestro es una misma hoja, cuando insertas la matricula y la fecha de nacimiento se llama así misma la hoja para cargar los datos. aqui les pongo el código:
Código PHP:
<html>
<head>
<title>Calificaciones de Licenciatura</title>
</head>
<body>
<h4>Resumen</h4>
<?php
// se verifica si ha sido rellamda la hoja
if (!$_REQUEST['Submit'])
{ html_form(); }
elseif ($_REQUEST['Submit'] == "VerBoleta")
{ select_cd(); }
include("conex.php");
$link=my_conn() {
function html_form() {
/* Calls Connection Function */
$conn = my_conn();
/* Defines query */
$sql = "SELECT DISTINCT grupos.mat FROM grupos;";
/* Passes query to database */
$result = mysql_query($sql, $conn);
if (!$result) {
echo("<p>Error performing query: " . mysql_error() . "</p>");
exit();
}
/* Outputs HTML form */
?>
<p>Dame la Matricula y la fecha de Nacimiento -formato (dia/mes/año)- para proporcionar Calificaciones</p>
<p>(Por ejemplo, 6 de Enero de 1978 seria "06011978")</p>
<form name="cds" method="post" action="todo.php">
<input name="mat" type="text" id="mat" size="30" maxlength="50"></td>
<input name="dob" type="text" id="dob" size="30" maxlength="50"></td>
<input type="submit" name="Submit" value="VerBoleta" />
</form>
<?
/* Closes Connection to the MySQL server */
mysql_close ($conn);
}
function select_cd() {
?>
<?
$conn=my_conn();
/* Defines the Active Database for the Connection */
if (!@mysql_select_db("Calificaciones", $conn)) {
echo "<p>There has been an error. This is the error message:</p>";
echo "<p><strong>" . mysql_error() . "</strong></p>";
echo "Please Contact Your Systems Administrator with the details";
}
?>
<?php
/* Retrieves the dob to validate */
$sql = "SELECT dianacimiento FROM Alumnos";
$sql .= " WHERE (Alumnos.matricula = '{$_POST['mat']}')";
$result = mysql_query($sql, $conn);
if (!$result) {
echo("<p>Error performing query: " . mysql_error() . "</p>");
exit();
}
$contador=0;
while ($row = mysql_fetch_array($result, MYSQL_ASSOC))
{
$contador=$contador+1;
$temporal=$row['dianacimiento'];
}
if (($contador <> 1) || ($temporal <> $_POST['dob'])) {
echo("<p>No son compatibles las fechas</p>");
mysql_close ($conn);
exit();
}
?>
<?
/* Sets the SQL Query for the ALUMNOS Table */
$sql = "SELECT * FROM Alumnos";
$sql .= " WHERE (Alumnos.matricula = '{$_POST['mat']}')";
/* Passes a Query to the Active Database for the ALUMNOS Table */
$result = mysql_query($sql, $conn);
if (!$result) {
echo("<p>Error performing query: " . mysql_error() . "</p>");
exit();
}
/* Starts the table and creates headings for the ALUMNOS Table */
?>
<table border="1">
<tr>
<td><font size="2" face="verdana"><strong>Matricula<img src="spacer.gif" width="10" height="1"></strong></font></td>
<td><font size="2" face="verdana"><strong>Nombre<img src="spacer.gif" width="10" height="1"></strong></font></td>
<td><font size="2" face="verdana"><strong>Carrera<img src="spacer.gif" width="10" height="1"></strong></font></td>
<td><font size="2" face="verdana"><strong>Semestre<img src="spacer.gif" width="10" height="1"></strong></font></td>
</tr>
<?
/* Retrieves the rows from the query result set
and puts them into a HTML table row for the ALUMNOS Table*/
while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
echo("<tr>\n<td align=\"center\"> <font size=\"1\" face=\"verdana\">" . $row["Matricula"] . "</font></td>");
echo("<td font size=\"1\" face=\"verdana\">" . $row["Nombre"] . "</font></td>");
echo("<td>" . $row["Carrera"] . "</td>");
echo("<td>" . $row["Semestre"] . "</td>");
}
/* Closes the table */
?>
</table>
<?
/* Sets the SQL Query for the DETALLE Table */
$sql = "SELECT * FROM Detalle";
$sql .= " WHERE (Detalle.matr = '{$_POST['mat']}')";
/* Passes a Query to the Active Database for the DETALLE Table */
$result = mysql_query($sql, $conn);
if (!$result) {
echo("<p>Error performing query: " . mysql_error() . "</p>");
exit();
}
/* Starts the table and creates headings for the DETALLE Table */
?>
<table>
<tr>
<td><strong>Clave</strong></td>
<td><strong>Nombre</strong></td>
<td><strong>Calificacion</strong></td>
<td><strong>Promedio de Grupo</strong></td>
<td><strong>Grupo</strong></td>
<td><strong>Calif Extraord</strong></td>
<td></td>
</tr>
<?
/* Retrieves the rows from the query result set
and puts them into a HTML table row for the DETALLE Table*/
while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
echo("<tr>\n<td>" . $row["Clave"] . "</td>");
echo("<td>" . $row["Nombre"] . "</td>");
echo("<td>" . $row["Calif"] . "</td>");
echo("<td>" . $row["Promgrupo"] . "</td>");
echo("<td>" . $row["Grupo"] . "</td>");
echo("<td>" . $row["Ext"] . "</td>");
}
/* Closes the table */
?>
</table>
<?
/* Sets the SQL Query for GRUPOS */
$sql = "SELECT * FROM grupos";
$sql .= " WHERE (grupos.mat = '{$_POST['mat']}')";
/* Passes a Query to the Active Database for GRUPOS */
$result = mysql_query($sql, $conn);
if (!$result) {
echo("<p>Error performing query: " . mysql_error() . "</p>");
exit();
}
/* Starts the table and creates headings for GRUPOS */
?>
<table>
<tr>
<td><strong>Grupo</strong></td>
<td><strong>Promedio</strong></td>
<td><strong>Lugar Ocupado</strong></td>
<td><strong># de Lugares</strong></td>
<td></td>
</tr>
<?
/* Retrieves the rows from the query result set
and puts them into a HTML table row for GRUPOS*/
while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
echo("<tr>\n<td>" . $row["gpo"] . "</td>");
echo("<td>" . $row["promedio"] . "</td>");
echo("<td>" . $row["lugar"] . "</td>");
echo("<td>" . $row["numlugares"] . "</td>");
}
/* Closes the table */
?>
</table>
<?
/* Closes Connection to the MySQL server */
mysql_close ($conn);
}
?>
</body>
</html>
Parse error: parse error, unexpected $ in /var/www/virtual/ulsacancun/php/boleta2.php on line 144
y la linea 144 ya es el final, en otro post de tema les pondre el codigo de la hoja ya con codigo para que se vea bonita...