Eje003.html:
Código HTML:
<head> <title>Sans Titre</title> <meta http-equiv="content-type" content="text/html; charset=iso-8859-1" /> <meta name="generator" content="HAPedit 3.1"> </head> <body bgcolor="#24A55C"><body bgcolor="#00FF00"> <b><u><h1 align="center">Pantalla para ingresar las Notas</h1></u></b> <hr /> <hr /> <hr /> <form action="procesar.php" name="frmIngresarNotas" method="get"> <center> Cedula:<br /> <input type="text" name="cedula" size="20" maxlength="20" /><br /> Nota 1:<br /> <input type="text" name="nota1" size="10" maxlength="5" /><br /> Nota 2: <br /> <input type="text" name="nota2" size="10" maxlength="5" /><br /> Nota 3: <br /> <input type="text" name="nota3" size="10" maxlength="5" /><br /> <input type="submit" name="procesar" value="Procesar" /> <input type="submit" name="borrar" value="Borrar" /> <input type="reset" name="limpiar" value="Limpiar Formulario" /></center> <br /> <br><a href="decision.html"><h3><center>Volver a Inicio</center></h3></a> <br> </form> <hr /> <h1 align="center"><font size="6">Creado por Ali&Johnny Corporation</font></h1> <br /><img src="f:/!00% upel 2.jpg" alt="" height="100" align="bottom" /> </body>
Código PHP:
// 1.Rescatar las Variables del Formulario
$cedula=$_GET['cedula'];
$nota1=$_GET['nota1'];
$nota2=$_GET['nota2'];
$nota3=$_GET['nota3'];
//2.Realizar las Operaciones requeridas
$promedio=($nota1+$nota2+$nota3)/3;
//3.Mostrar los Resultados
echo "<h1>Reporte de los Alumnos UPEL</h1>";
echo "Cedula del Alumno: $cedula<br>";
echo "Nota 1: $nota1<br>";
echo "Nota 2: $nota2<br>";
echo "Nota 3: $nota3<br>";
echo "Promedio: $promedio<br>";
//Pasos para Guardar en BD
//1.Conectar con MySQL
$conectar=mysql_connect("localhost","root","");
//2.Seleccionar BD
mysql_select_db("control");
//3.Asignar variable SQL
$sql="INSERT INTO notas VALUES('$cedula',$nota1,$nota2,$nota3)";
//4.Ejecutar Consulta (QUERY)
$resultado=mysql_query($sql);
//5.Atrapar el Error
echo mysql_error();
Código PHP:
<?
// Your code here
//1.Conectar con el MYSQL
$conectar=mysql_connect("localhost","root","");
//2. Seleccionar Base de Datos
mysql_select_db("control");
//3. Asignar Variable SQL
$sql="SELECT * FROM notas";
//4. Ejecutar la Consulta SQL
$resultado=mysql_query($sql);
echo mysql_error();
$nroregistro=mysql_num_rows($resultado);
?><center>
<h1>Tabla de Actualizacion de Notas</h1>
<table border="2" bgcolor="#80FF00" borderColorDark="#000000"></center>
<?
for($i=0;$i<$nroregistro;$i++){
$valores=mysql_fetch_array($resultado);
$promedio=($valores[1]+$valores[2]+$valores[3])/3;
?>
<tr align="center" valign="middle">
<td><?echo $valores[0];?></td>
<td><?echo $valores[1];?></td>
<td><?echo $valores[2];?></td>
<td><?echo $valores[3];?></td>
<td><?echo $promedio;?></td>
<td><a href="actualizar.php?clave=<?echo $valores[0];?>">Actualizar</a>/
<a href="borrar.php?clave=<?echo $valores[0];?>">Borrar</a>
</td>
</tr>
<?
}
?>
Código PHP:
<?
// Your code here
$clave=$_REQUEST['clave'];
if($_GET['procesar']=="Actualizar"){
// rescatar variables
$cedula=$_GET['cedula'];
$nota1=$_GET['nota1'];
$nota2=$_GET['nota2'];
$nota3=$_GET['nota3'];
echo $cedula;
// 1 CONECTAR CON EL MYSQL
$conectar=mysql_connect("localhost","root","");
// 2 SELECCIONAR BASE DE DATOS
mysql_select_db("control");
// 3 ASIGNAR VARIABLE SQL
$sql="UPDATE notas SET nota1=$nota1,
nota2=$nota2,
nota3=$nota3
WHERE cedula='$cedula'";
// 4 EJECUTAR LA CONSULTA SQL
$resultado=mysql_query($sql);
echo mysql_error();
$clave=$cedula;
}
// 1 CONECTAR CON EL MYSQL
$conectar=mysql_connect("localhost","root","");
// 2 SELECCIONAR BASE DE DATOS
mysql_select_db("control");
// 3 ASIGNAR VARIABLE SQL
$sql="SELECT * FROM notas WHERE cedula='$clave'";
// 4 EJECUTAR LA CONSULTA SQL
$resultado=mysql_query($sql);
echo mysql_error();
$valores=mysql_fetch_array($resultado);
?>
<h1>Pantalla para actualizar las notas</h1>
<form action="actualizar.php" name="frmIngresarNotas" method="get">
Cedula:<input type="text"
name="cedula"
size="20"
maxlength="20"
value=<?echo $valores[0];?> /><br />
Nota 1:<input type="text"
name="nota1"
size="10"
maxlength="5"
value=<?echo $valores[1];?> /><br />
Nota 2:<input type="text"
name="nota2"
size="10"
maxlength="5"
value=<?echo $valores[2];?> /><br />
Nota 3:<input type="text"
name="nota3"
size="10"
maxlength="5"
value=<?echo $valores[3];?> /><br />
<input type="submit" name="procesar" value="Actualizar" />
<input type="reset" name="limpiar" value="Limpiar" />
</form>
<br><a href="eje004.php"><h4>CONSULTAR ACTUALIZACION</h4></a> <br>
<?
?>
borrar.php:
Código PHP:
<?
$clave=$_REQUEST['clave'];
if($_GET['procesar']=="Actualizar"){
// rescatar variables
$cedula=$_GET['cedula'];
$nota1=$_GET['nota1'];
$nota2=$_GET['nota2'];
$nota3=$_GET['nota3'];
echo $cedula;
// 1 CONECTAR CON EL MYSQL
$conectar=mysql_connect("localhost","root","");
// 2 SELECCIONAR BASE DE DATOS
mysql_select_db("control");
// 3 ASIGNAR VARIABLE SQL
$sql="DELETE * FROM notas WHERE cedula='$cedula'";
// 4 EJECUTAR LA CONSULTA SQL
$resultado=mysql_query($sql);
echo mysql_error();
$valores=mysql_fetch_array($resultado);
}
// 1 CONECTAR CON EL MYSQL
$conectar=mysql_connect("localhost","root","");
// 2 SELECCIONAR BASE DE DATOS
mysql_select_db("control");
// 3 ASIGNAR VARIABLE SQL
$sql="SELECT * FROM notas WHERE cedula='$clave'";
// 4 EJECUTAR LA CONSULTA SQL
?>
<h1>Pantalla para actualizar las notas</h1>
<form action="borrar.php" name="frmIngresarNotas" method="get">
Cedula:<input type="text"
name="cedula"
size="20"
maxlength="20"
value=<?echo $valores[0];?> /><br />
Nota 1:<input type="text"
name="nota1"
size="10"
maxlength="5"
value=<?echo $valores[1];?> /><br />
Nota 2:<input type="text"
name="nota2"
size="10"
maxlength="5"
value=<?echo $valores[2];?> /><br />
Nota 3:<input type="text"
name="nota3"
size="10"
maxlength="5"
value=<?echo $valores[3];?> /><br />
<input type="submit" name="procesar" value="Actualizar" />
<input type="reset" name="limpiar" value="Limpiar" />
</form>
<br><a href="eje004.php"><h4>CONSULTAR ACTUALIZACION</h4></a> <br>
<?