Ver Mensaje Individual
  #1 (permalink)  
Antiguo 13/04/2014, 18:48
memoone1
 
Fecha de Ingreso: abril-2014
Mensajes: 2
Antigüedad: 10 años
Puntos: 0
crear consulta para reporte de notas php

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


y yo quiero que quede asi



mi codigo es hecho en dreamweaver

Código PHP:
Ver original
  1. <?php
  2.  
  3. $var=0;
  4.  
  5. if (!function_exists("GetSQLValueString")) {
  6. function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
  7. {
  8.   if (PHP_VERSION < 6) {
  9.     $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
  10.   }
  11.  
  12.   $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
  13.  
  14.   switch ($theType) {
  15.     case "text":
  16.       $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
  17.       break;    
  18.     case "long":
  19.     case "int":
  20.       $theValue = ($theValue != "") ? intval($theValue) : "NULL";
  21.       break;
  22.     case "double":
  23.       $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
  24.       break;
  25.     case "date":
  26.       $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
  27.       break;
  28.     case "defined":
  29.       $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
  30.       break;
  31.   }
  32.   return $theValue;
  33. }
  34. }
  35.  
  36. $colname_notas = "-1";
  37. if (isset($_GET['codigo'])) {
  38.   $colname_notas = $_GET['codigo'];
  39. }
  40. mysql_select_db($database_notas, $notas);
  41. $query_notas = sprintf("SELECT * FROM notas WHERE codigo_estudiante = %s", GetSQLValueString($colname_notas, "int"));
  42. $notas = mysql_query($query_notas, $notas) or die(mysql_error());
  43. $row_notas = mysql_fetch_assoc($notas);
  44. $totalRows_notas = mysql_num_rows($notas);
  45.  
  46.  
  47. <p><?php
  48.  $nombre=$_GET['nombre'];
  49.   $apellido=$_GET['apellidos'];
  50.   $clei=$_GET['clei'];
  51.    
  52.    
  53.         if(empty($_SESSION['usuario_nombre'])) { // comprobamos que las variables de sesión estén vacías  
  54.        
  55.            echo "Estás accediendo a una página restringida, para ver su contenido debes estar registrado.<br />"; } else     {
  56.     ?>
  57.     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>
  58.     <form id="form1" name="form1" method="get" action="ver_notas.php"  >
  59.       <label for="atras"></label>
  60.       <input name="clei" OnFocus="this.blur()" type="text" id="atras" value="<?php echo $clei; ?>" size="7" />
  61. <input type="submit" name="enviar" id="volver" value="&lt;&lt;" />
  62.     </form>
  63. <p>&nbsp;</p>
  64. <p>Boletin de Notas
  65.       <?php    
  66.  
  67.  
  68.  
  69.   echo $nombre;
  70.   echo $apellido; ?> <br> <?php
  71.  
  72.   echo date ("M-d-Y");
  73.  
  74.  
  75.  
  76.    ?><a href="javascript:window.print()"></a></p>
  77. <table border="0" align="center">
  78.   <tr class="d">
  79.     <td bgcolor="#0000FF">Materia</td>
  80.     <td bgcolor="#0000FF">Clei</td>
  81.     <td bgcolor="#0000FF">Periodo</td>
  82.     <td bgcolor="#0000FF">Evaluacion 35%</td>
  83.     <td bgcolor="#0000FF">Guias 35%</td>
  84.     <td bgcolor="#0000FF">Asistencia 25%</td>
  85.     <td bgcolor="#0000FF">Cualitativa 5%</td>
  86.     <td bgcolor="#0000FF">Final 100%</td>
  87.     <td bgcolor="#0000FF">&nbsp;</td>
  88.   </tr>
  89.   <?php do { ?>
  90.  
  91.  
  92.   <?php $final=$row_notas['evaluacion']*35/100+$row_notas['guias']*35/100+$row_notas['asistencia']*25/100+$row_notas['cualitativa']*5/100; ?>
  93.  
  94.     <tr align="center">
  95.       <td bgcolor="#FFFF99"><?php echo $row_notas['materia']; ?></td>
  96.       <td bgcolor="#FFFF99"><?php echo $row_notas['clei']; ?></td>
  97.       <td bgcolor="#FFFF99"><?php echo $row_notas['periodo']; ?></td>
  98.       <td><?php echo $row_notas['evaluacion']; ?></td>
  99.       <td><?php echo $row_notas['guias']; ?></td>
  100.       <td><?php echo $row_notas['asistencia']; ?></td>
  101.       <td><?php echo $row_notas['cualitativa']; ?></td>
  102.       <td><?php if ($final<3){
  103.          ?> <font color="#FF0000"> <b> <?php echo $final; ?></b> </font> <?php
  104.           }
  105.       else
  106.      
  107.     {
  108.    
  109.     echo $final;
  110.    
  111.     }  
  112.      
  113.       ?></td>
  114.       <td><a href="modifica_notas.php?codigo=<?php echo $row_notas['codigo_estudiante'];
  115.      
  116.         $var += $final;
  117.  
  118.       ?>"><img src="images/Note14.ico" /></a></td>
  119.      
  120.     </tr>
  121.     <?php } while ($row_notas = mysql_fetch_assoc($notas)); ?>
  122. </table>
  123.   <p><?php    
  124.      
  125.      $var2= $var / $totalRows_notas;
  126.      
  127.      
  128.    
  129.     if ($var2<3){
  130.          ?> <font color="#FF0000"> <b> <?php    echo "Nota Final". "  " .number_format($var2,2,".",",");
  131.  ?></b> </font>
  132.        
  133.         <?php
  134.           }
  135.       else
  136.      
  137.     {
  138.    
  139.     echo "Nota Final". "  " .number_format($var2,2,".",",");
  140.  
  141.    
  142.     }  
  143.    
  144.    
  145.    
  146.    
  147.     ?></p>
  148.   <p>&nbsp;</p>
  149.   <p>&nbsp;</p>
  150.   <p>&nbsp;</p>
  151.   <p>&nbsp;</p>
  152.   <table width="612" height="33" border="0" align="left">
  153.     <tr>
  154.       <td width="301">Secretaria </td>
  155.       <td width="301" align="right">         Directora</td>
  156.     </tr>
  157.   </table>
  158. <p>&nbsp;</p>
  159. <p>
  160.   <?php } ?>
  161. </p>
  162.   </div>
  163.   <div class="footer">
  164.     <p>Todos los derechos reservados colegio sedi 2013</p>
  165.     <!-- end .footer --></div>
  166.   <!-- end .container --></div>
  167. </body>
  168. </html>
  169. <?php
  170. ?>

Última edición por Triby; 13/04/2014 a las 23:14 Razón: Código en highlight