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- <?php 
-   
- $var=0; 
-   
- function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")  
- { 
-   if (PHP_VERSION < 6) { 
-   } 
-   
-   
-   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']; 
- } 
- $query_notas = sprintf("SELECT * FROM notas WHERE codigo_estudiante = %s",-  GetSQLValueString ($colname_notas, "int"));
 
-   
-    
- <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 
-    
-    
-    
-    
-    ?><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> 
- </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 
-        
-     { 
-      
-   
-      
-     }   
-      
-      
-      
-      
-     ?></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 
- ?>