crear consulta para reporte de notas php
Publicado por guillermo (14 intervenciones) el 03/05/2014 05:44:29
buenas tardes este es mi primer pregunta en un foro, resulta que estoy creando una aplicación de notas para un colegio donde debo imprimir el reporte
cuando realizo la consulta por estudiante el me muestra todos los registros
lo que yo necesito es que al frente de cada materia aparezca la nota de cada periodo
ej lo tengo así.
http://www.creatupaginafacil.com/notasimg/Sin-t%edtulo-2.jpg
y yo quiero que quede asi
http://www.creatupaginafacil.com/notasimg/Sin-t%edtulo-4.jpg
Tengo una tabla materia que contiene los campos [ id ]- [ materia]
y una tabla {notas} que contiene campo [ id]- [materia] - [codigo_estudiante] - [clei] - [periodo] - [evaluacion] -[guias] - [asistencia] - [cualitativa ]-[final]
mi codigo es hecho en dreamweavaer
cuando realizo la consulta por estudiante el me muestra todos los registros
lo que yo necesito es que al frente de cada materia aparezca la nota de cada periodo
ej lo tengo así.
http://www.creatupaginafacil.com/notasimg/Sin-t%edtulo-2.jpg
y yo quiero que quede asi
http://www.creatupaginafacil.com/notasimg/Sin-t%edtulo-4.jpg
Tengo una tabla materia que contiene los campos [ id ]- [ materia]
y una tabla {notas} que contiene campo [ id]- [materia] - [codigo_estudiante] - [clei] - [periodo] - [evaluacion] -[guias] - [asistencia] - [cualitativa ]-[final]
mi codigo es hecho en dreamweavaer
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
<?php
$var=0;
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
if (PHP_VERSION < 6) {
$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_notas = "-1";
if (isset($_GET['codigo'])) {
$colname_notas = $_GET['codigo'];
}
mysql_select_db($database_notas, $notas);
$query_notas = sprintf("SELECT * FROM notas WHERE codigo_estudiante = %s", GetSQLValueString($colname_notas, "int"));
$notas = mysql_query($query_notas, $notas) or die(mysql_error());
$row_notas = mysql_fetch_assoc($notas);
$totalRows_notas = mysql_num_rows($notas);
session_start(); ?>
<p><?php
$nombre=$_GET['nombre'];
$apellido=$_GET['apellidos'];
$clei=$_GET['clei'];
if(empty($_SESSION['usuario_nombre'])) { // comprobamos que las variables de sesión estén vacías
echo "Estás accediendo a una página restringida, para ver su contenido debes estar registrado.<br />"; } else {
?>
Usuario: <a href="perfil.php?id=<?=$_SESSION['usuario_id']?>"><strong><?=$_SESSION['usuario_nombre']?></strong></a> <a href="javascript:window.print()">Imprimir esta página</a></p>
<form id="form1" name="form1" method="get" action="ver_notas.php" >
<label for="atras"></label>
<input name="clei" OnFocus="this.blur()" type="text" id="atras" value="<?php echo $clei; ?>" size="7" />
<input type="submit" name="enviar" id="volver" value="<<" />
</form>
<p> </p>
<p>Boletin de Notas
<?php
echo $nombre;
echo $apellido; ?> <br> <?php
date_default_timezone_set('UTC');
echo date ("M-d-Y");
?><a href="javascript:window.print()"></a></p>
<table border="0" align="center">
<tr class="d">
<td bgcolor="#0000FF">Materia</td>
<td bgcolor="#0000FF">Clei</td>
<td bgcolor="#0000FF">Periodo</td>
<td bgcolor="#0000FF">Evaluacion 35%</td>
<td bgcolor="#0000FF">Guias 35%</td>
<td bgcolor="#0000FF">Asistencia 25%</td>
<td bgcolor="#0000FF">Cualitativa 5%</td>
<td bgcolor="#0000FF">Final 100%</td>
<td bgcolor="#0000FF"> </td>
</tr>
<?php do { ?>
<?php $final=$row_notas['evaluacion']*35/100+$row_notas['guias']*35/100+$row_notas['asistencia']*25/100+$row_notas['cualitativa']*5/100; ?>
<tr align="center">
<td bgcolor="#FFFF99"><?php echo $row_notas['materia']; ?></td>
<td bgcolor="#FFFF99"><?php echo $row_notas['clei']; ?></td>
<td bgcolor="#FFFF99"><?php echo $row_notas['periodo']; ?></td>
<td><?php echo $row_notas['evaluacion']; ?></td>
<td><?php echo $row_notas['guias']; ?></td>
<td><?php echo $row_notas['asistencia']; ?></td>
<td><?php echo $row_notas['cualitativa']; ?></td>
<td><?php if ($final<3){
?> <font color="#FF0000"> <b> <?php echo $final; ?></b> </font> <?php
}
else
{
echo $final;
}
?></td>
<td><a href="modifica_notas.php?codigo=<?php echo $row_notas['codigo_estudiante'];
$var += $final;
?>"><img src="images/Note14.ico" /></a></td>
</tr>
<?php } while ($row_notas = mysql_fetch_assoc($notas)); ?>
</table>
<p><?php
$var2= $var / $totalRows_notas;
if ($var2<3){
?> <font color="#FF0000"> <b> <?php echo "Nota Final". " " .number_format($var2,2,".",",");
?></b> </font>
<?php
}
else
{
echo "Nota Final". " " .number_format($var2,2,".",",");
}
?></p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<table width="612" height="33" border="0" align="left">
<tr>
<td width="301">Secretaria </td>
<td width="301" align="right"> Directora</td>
</tr>
</table>
<p> </p>
<p>
<?php } ?>
</p>
</div>
<div class="footer">
<p>Todos los derechos reservados colegio sedi 2013</p>
<!-- end .footer --></div>
<!-- end .container --></div>
</body>
</html>
<?php
mysql_free_result($notas);
?>
Valora esta pregunta


0