PROBLEMA CON SELECT Y WHILE
Publicado por felipe largacha (14 intervenciones) el 16/01/2007 06:34:41
ES QUE ESTOY HACIENDO UN ENTORNO DE NOTAS Y ME SUCEDE LO SIGUIENTE
ESTE ES EL CODIGO
<body>
<div align="center">
<p>CALIFICACIONES</p>
<p align="left"> </p>
<form name="form1" method="post" action="calificacionesmateria.php">
<p align="left">Materia:
<select name="materia">
<?php
include("conec.php");
$link=Conectarse();
$result=mysql_query("select * from materias",$link);
while($row = mysql_fetch_row($result))
{ printf("<option value=%s>%s</option>", $row[0],$row[1]); }
mysql_free_result($result);
?>
</select>
<?php
$Sql="select alumnos.nombre , alumnos.apellido , calificaciones.nota1 , calificaciones.nota2 , calificaciones.nota3 , calificaciones.prom from alumnos,materias,calificaciones where idm like '%$materia%'";
$result=mysql_query($Sql,$link); ?>
<input type="submit" name="Submit" value="BUSCAR">
</form>
<p align="left"> </p>
<p align="left"> </p>
</div>
</body>
</html>
<hr>
</table>
<FORM METHOD=POST ACTION="modificar.php">
<TABLE BORDER=1 CELLSPACING=1 CELLPADDING=1> <TR> <TD> nombre</TD> <TD> apellido</TD> <TD> nota1 </TD> <TD> nota2 </TD> <TD> nota3 </TD> <TD> prom </TD></TR>
<?php
echo $Sql;
while($row = mysql_fetch_array($result))
{
printf("<tr><td> %s</td><td> %s</td><td> %s</td><td> %s</td><td> %s</td><td> %s</td></tr>", $row["nombre"],$row["apellido"],$row["nota1"],$row["nota2"],$row["nota3"],$row["prom"]);
}
mysql_free_result($result);
?> </table>
</FORM>
</body>
</html>
Y EL RESULTADO ME APARECE :
nombre apellido nota1 nota2 nota3 prom
felipe lara 50 40 45 30
YULEIDY LARROTE 50 40 45 30
felipe lara 50 50 50 50
YULEIDY LARROTE 50 50 50 50
Y DEBERIA PARECER
nombre apellido nota1 nota2 nota3 prom
YULEIDY LARROTE 50 40 45 30
felipe lara 50 50 50 50
QUE ESTA PASANDO
ESTE ES EL CODIGO
<body>
<div align="center">
<p>CALIFICACIONES</p>
<p align="left"> </p>
<form name="form1" method="post" action="calificacionesmateria.php">
<p align="left">Materia:
<select name="materia">
<?php
include("conec.php");
$link=Conectarse();
$result=mysql_query("select * from materias",$link);
while($row = mysql_fetch_row($result))
{ printf("<option value=%s>%s</option>", $row[0],$row[1]); }
mysql_free_result($result);
?>
</select>
<?php
$Sql="select alumnos.nombre , alumnos.apellido , calificaciones.nota1 , calificaciones.nota2 , calificaciones.nota3 , calificaciones.prom from alumnos,materias,calificaciones where idm like '%$materia%'";
$result=mysql_query($Sql,$link); ?>
<input type="submit" name="Submit" value="BUSCAR">
</form>
<p align="left"> </p>
<p align="left"> </p>
</div>
</body>
</html>
<hr>
</table>
<FORM METHOD=POST ACTION="modificar.php">
<TABLE BORDER=1 CELLSPACING=1 CELLPADDING=1> <TR> <TD> nombre</TD> <TD> apellido</TD> <TD> nota1 </TD> <TD> nota2 </TD> <TD> nota3 </TD> <TD> prom </TD></TR>
<?php
echo $Sql;
while($row = mysql_fetch_array($result))
{
printf("<tr><td> %s</td><td> %s</td><td> %s</td><td> %s</td><td> %s</td><td> %s</td></tr>", $row["nombre"],$row["apellido"],$row["nota1"],$row["nota2"],$row["nota3"],$row["prom"]);
}
mysql_free_result($result);
?> </table>
</FORM>
</body>
</html>
Y EL RESULTADO ME APARECE :
nombre apellido nota1 nota2 nota3 prom
felipe lara 50 40 45 30
YULEIDY LARROTE 50 40 45 30
felipe lara 50 50 50 50
YULEIDY LARROTE 50 50 50 50
Y DEBERIA PARECER
nombre apellido nota1 nota2 nota3 prom
YULEIDY LARROTE 50 40 45 30
felipe lara 50 50 50 50
QUE ESTA PASANDO
Valora esta pregunta


0