Good I am something new in the programming and I am doubtful with respect to how to do the following, I have a system in php linked to mysql.
I have a record made in php that sends me the data to a table called 'students' which has:
estudiantes
-------------
cedula(key),
apellido,
nombre,
carrera,
turno,
seccion,
email.
and I want to do in the same way a record of: grupos
but to register a group of students I want you to ask me:
ID_grupo(key) AUTO_INCREMENT,
proyecto,
cod_parroquia,
lugar,
habitantes,
cod_periodo.
These would be data that give me information about the group, once that data is filled by the user:
And through that I must take into account all the data entered in the table 'students' example: group ID_grupo=00001
has 4 students, shows me (all information group information) and at the same time all the data of the table 'students' of those 4 that enter in my system so that they would be registered along with that ID_grupo
that would be my key field.
I appreciate any advice, examples, code structure, but what confuses me the most is how the database is with that, the tables and fields, I do not know how to enter several data of the same type in the same record
here the code:
<?php
include ('control.php');
$boton= $_POST['boton'];
$idgrupo= $_POST['idgrupo'];
$num_int= $_POST['num_int'];
$ced_alum= $_POST['ced_alum'];
$op= $_POST['op'];
if ($boton=="Guardar") {
$sql="insert into grupo ()
values ('')";
if (mysql_query($sql)) {
echo "<script> alert ('Data Almacenda')</script>";
echo "<script> window.location='registro.php'</script>";
} else {
echo "<script> alert ('No Guardado')</script>";
}
}
?>
<!DOCTYPE html>
<html>
<head>
<title>Registro de grupos</title>
<meta charset="utf-8">
</head>
<body>
<form method="post" action="">
<h1>Creacion del Grupo:</h1>
<p><label>Grupo Nro:</label> <input type="text" name="idgrupo" readonly placeholder="Número predeterminado"></p>
<p>
<label>Carrera:</label>
<select name="carrera" required="">
<option>Seleccionar</option>
<option>Administración agropecuaria</option>
<option>Administración de empresas</option>
<option>Gastronomía</option>
<option>Informática</option>
<option>Turismo</option>
</select>
</p>
<p>
<label>Turno</label>
<select name="turno">
<option>Seleccionar</option>
<option>Matutino</option>
<option>Vepertino</option>
<option>Sabatino</option>
</select>
</p>
<p>
<label>Período académico:</label><input type="text" name="periodo" placeholder="(I-2000)(II-2000)(III-2000)">
</p>
<p><label><h1>Integrantes:</h1></label></p>
<p><label>Numero de integrantes:</label><input type="number" name="op"></p>
<?php
switch ($op) {
case 1:
// se deben abrir tantas cajas de texto para registro como numeros se ingresen en "Numero de integrantes"
break;
default:
break;
}
?>
# Estás son las cajas de texto que se deben abrir dependiendo de cuantos numeros sean los integrantes, de modo que se ingrese la cedula y ya me tome en cuenta todos los datos ya ingresados en la tabla estudiantes
<p>
<label>Cédula: </label><input type="text" name="ced_alumno">
</p>
<p>
<label>Cédula: </label><input type="text" name="ced_alumno">
</p>
<p>
<label>Cédula: </label><input type="text" name="ced_alumno">
</p>
<p>
<label>Cédula: </label><input type="text" name="ced_alumno">
</p>
<p>
<label>Cédula: </label><input type="text" name="ced_alumno">
</p>
<p>
<label>Cédula: </label><input type="text" name="ced_alumno">
</p>
<p><input type="submit" name="boton" value="Guardar"></p>
<p><input type="submit" name="boton" value="Limpiar"></p>
<p><a href="http://localhost/sercom/menu3.php">Volver</a></p>
</p>
</form>
</body>
</html>