Ver Mensaje Individual
  #5 (permalink)  
Antiguo 12/06/2011, 06:48
yessyherrera89
 
Fecha de Ingreso: junio-2011
Mensajes: 3
Antigüedad: 12 años, 11 meses
Puntos: 0
Respuesta: Necesito un codigo para presentar un formulario?

Hola gracias skkiper, por tu buena y educada respuesta, y a los demas por sus aclaraciones tambien gracias.

X fa necesito q me ayuden no es q sea comoda sino q no se como hacerlo, aki les posteo los codigos por fa para q me den la idea de como podria hacer

Importante: yo trabajo con la libreria adodb5, tambien aclaro que la tabla matricula y la tabla materia no tiene relacion, ambas se relacionan mediante la tabla carrera.

1. Este es el codigo de ingresar materia:

<?php
if(!isset($_SESSION))
{
session_start();
}

if($_SESSION["usuario"]==NULL)
{
header("Location:login.php");
}

include "conexion.php";
$dbcon = conectar();
if
if (isset ($_POST["btnGuardar"]))
{
$cod = md5(uniqid(rand ()));
$alu = $_POST["cboAlu"];
$per = $_POST["cboSem"];
$car = $_POST["cboCar"];
$niv = $_POST["cboNiv"];
$res = $dbcon->Execute ("insert into matricula values ('$cod','$alu','$per','$niv','$car')");
if (!$res)
{
echo $dbcon->ErrorMsg ();
}
else
{
header("Location:materias.php?cod=".$cod."&car=".$ car."&alu=".$alu);
}
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>

<body>
<form id="form1" name="form1" method="post" action="ingresar_matricula.php">
<table width="200" border="1">
<tr>
<td>Alumno</td>
<td><label>
<select name="cboAlu" id="cboAlu">
<?php $rsalu = $dbcon -> Execute ("select * from alumno");
while(!$rsalu -> EOF)
{
echo "<option value=".$rsalu->fields[0].">".$rsalu->fields[1]." ".$rsalu->fields[2]."</option>";
$rsalu->MoveNext ();
}
?>
</select>
</label></td>
</tr>
<tr>
<td>Semestre</td>
<td><select name="cboSem" id="cboSem">
<?php $rssem = $dbcon -> Execute ("select * from periodo");
while(!$rssem -> EOF)
{
echo "<option value=".$rssem->fields[0].">".$rssem->fields[1]." </option>";
$rssem->MoveNext ();
}
?>
</select></td>
</tr>
<tr>
<td>Carrera</td>
<td><select name="cboCar" id="cboCar">
<?php $rscar = $dbcon -> Execute ("select * from carrera");
while(!$rscar -> EOF)
{
echo "<option value=".$rscar->fields[0].">".$rscar->fields[1]." </option>";
$rscar->MoveNext ();
}
?>
</select></td>
</tr>
<tr>
<td>Nivel</td>
<td><select name="cboNiv" id="cboNiv">
<?php $rsniv = $dbcon -> Execute ("select * from nivel");
while(!$rsniv -> EOF)
{
echo "<option value=".$rsniv->fields[0].">".$rsniv->fields[1]." </option>";
$rsniv->MoveNext ();
}
?>
</select></td>
</tr>
<tr>
<td>&nbsp;</td>
<td><label>
<input name="btnGuardar" type="submit" id="btnGuardar" value="Guardar y Asignar Materias" />
</label></td>
</tr>
</table>
</form>
</body>
</html>

2. Al dar click en el boton "Guardar y Asignar Materias" ,
se dirige a este archivo lllamado materias, donde unicamente aparece ya cargado el nombre del alumno matriculado:

<?php
include "conexion.php";
$dbcon=conectar();

if(isset($_POST["btnMaterias"]))
{
$mtr =$_POST["txtMtr"];
foreach($_POST["materias"] as $mat)
{
//echo $mat."<br>";
$res=$dbcon->Execute("insert into notas values(0,'$mtr','$mat',0,0,0,0,'T')");
header ("Location:mostrar_matricula.php?cod=$mtr");
}
}


$mtr=$_GET["cod"];
$car=$_GET["car"];
$alu=$_GET["alu"];
$rsAlu=$dbcon->Execute("select * from alumno where cod_alu='$alu'");
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Documento sin t&iacute;tulo</title>
</head>

<body>
<form id="form1" name="form1" method="post" action="">
<table border="1">
<tr>
<td>ALUMNO</td>
<td><?php echo $rsAlu->fields[1]." ".$rsAlu->fields[2]; ?>&nbsp;</td>
</tr>
<tr>
<td><input name="txtMtr" type="hidden" id="txtMtr" value="<?php echo $mtr; ?>" /></td>
<td><input name="btnMaterias" type="submit" id="btnMaterias" value="Tomar Materias" /></td>
</tr>
</table>
<p>&nbsp;</p>
<table width="200" border="1">
<tr>
<td>MATERIAS</td>
<td>&nbsp;</td>
</tr>
<?php
$rsMat=$dbcon->Execute("select * from materia where cod_car='$car'");
while( ! $rsMat->EOF)
{
?>
<tr>
<td><?php echo $rsMat->fields[1]; ?>&nbsp;</td>
<td><input type="checkbox" name="materias[]" value="<?php echo $rsMat->fields[0]; ?>" /></td>
</tr>
<?php
$rsMat->MoveNext();
}
?>
</table>
<p>&nbsp;</p>
</form>
</body>
</html>

3. Como se pueden dar cuenta se toma las materias seleccionando mediente checkbox, aki mi duda para que en el siguiente archivo al dar click en el boton "Tomar materias", se me debe ir al archivo del reporte donde solo se dene mostrar las materiuas que el alumno esta tomando,no todas..... ayudaaa... aki esta el codigo de lo q yo tengo realizado hasta el momento.

<?php
include "conexion.php";
$dbcon = conectar ();
$mtr=$_GET["cod"];

$res = $dbcon -> Execute ("select * from matricula, alumno where matricula.cod_alu= alumno.cod_alu and cod_mtr='$mtr'");
$rscar = $dbcon -> Execute ("select * from matricula, carrera where matricula.cod_car= carrera.cod_car and cod_mtr='$mtr'");
$rsniv = $dbcon -> Execute ("select * from matricula, nivel where matricula.cod_niv= nivel.cod_niv and cod_mtr='$mtr'");


?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>

<body>
<table width="200" border="1">
<tr>
<td><label>Alumno</label></td>
<td>Carrera</td>
<td>Nivel</td>
</tr>
<?php
while (! $res -> EOF)
{
?>
<tr>
<td>&nbsp;<?php echo $res->fields [6];?></td>
<td>&nbsp;<?php echo $rscar->fields [6];?></td>
<td>&nbsp;<?php echo $rsniv->fields [6];?></td>
</tr>
<?php

$res->MoveNext();
}
?>
</table>
<p>&nbsp;</p>
<p>&nbsp;</p>
<table width="200" border="1">
<tr>
<td>Materias</td>
</tr>
<?php
$rsMat=$dbcon->Execute("select * from materia where cod_car='$car'");

while( ! $rsMat->EOF)
{
?>
<tr>
<td>&nbsp;<?php $rsMat=$dbcon->Execute("select * from matricula where cod_car='$car' and cod_mtr='$mtr'");
echo $rsMat->fields[1]; ?></td>
</tr>
<?php
$rsMat->MoveNext();
}
?>
</table>
<p>&nbsp;</p>
</body>
</html>

Por fa chic@s, necesito que me ayuden.... no es q kiera que ningun "nerd" lo haga, sino que se que muchos de ustedes tiene mayor conocimiento en esto...

Gracias...