I have a system to register students to projects that have a university (projects table), which should not be in another project.
This system allows me to see a list of students who have the ability to be registered to enroll them, before it even showed those who were already in projects, so I got the following function
function bd_alumno_opciones($proy_id_seleccionado){
$sql = "SELECT cedu_alum,";
$sql .= " CONCAT(nom1_alum,' ',nom2_alum,' ',ape1_alum,' ',ape2_alum,' ',cedu_alum) ";
$sql .= " FROM alumno LEFT JOIN proyecto_alumno ON cedu_alum = alum_id ";
$sql .= " WHERE proy_id = $proy_id_seleccionado OR proy_id is null ORDER BY cedu_alum ASC";
$res = sql2options( $sql );
return $res; }
This allows you to show those that are not enrolled in another project, the problem is that it only works when you want to modify a project to add or delete students, but when I want to register them I get an error, because there is no variable that compares them
MYSQL USE
I would like to have a function that shows those that are not with projects to register them, and that also helps me to modify a project taking that ID of the project
PUPILS TABLE
CREATE TABLE 'alumno' (
'cedu_alum' int(9) UNSIGNED NOT NULL COMMENT 'Cédula',
'ape1_alum' varchar(50) COLLATE utf8_unicode_ci NOT NULL,
'ape2_alum' varchar(50) COLLATE utf8_unicode_ci NOT NULL,
'nom1_alum' varchar(50) COLLATE utf8_unicode_ci NOT NULL,
'nom2_alum' varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL,
'fech_naci' date NOT NULL,
'telf_resi_alum' varchar(11) COLLATE utf8_unicode_ci NOT NULL,
'telf_celu_alum' varchar(11) COLLATE utf8_unicode_ci DEFAULT NULL,
'emai_alum' varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL,
'carr_id' int(2) NOT NULL,
'seme_id' int(2) NOT NULL,
'pera_id' int(1) NOT NULL,
'peri_id' int(1) NOT NULL,
'capa_id' int(1) NOT NULL
PROJECT TABLE
CREATE TABLE 'proyecto' (
'proy_id' int(4) UNSIGNED NOT NULL,
'proy_deno' varchar(100) COLLATE utf8_unicode_ci NOT NULL,
'plan_proy' varchar(100) COLLATE utf8_unicode_ci NOT NULL,
'objg_proy' varchar(100) COLLATE utf8_unicode_ci NOT NULL,
'obje_proy' varchar(100) COLLATE utf8_unicode_ci NOT NULL,
'fech_insc' date NOT NULL,
'nomb_comu' varchar(50) COLLATE utf8_unicode_ci NOT NULL,
'resp_comu' varchar(50) COLLATE utf8_unicode_ci NOT NULL,
'parr_id' int(4) NOT NULL,
'deta' varchar(100) COLLATE utf8_unicode_ci NOT NULL,
'esta_proy_id' int(1) NOT NULL,
'telf_inst' varchar(11) COLLATE utf8_unicode_ci NOT NULL,
'telf_resp' varchar(11) COLLATE utf8_unicode_ci NOT NULL,
'obsv_proy' varchar(255) COLLATE utf8_unicode_ci NOT NULL,
'proy_carr_id' int(2) NOT NULL
TABLE PROJECT_ALUMNO
CREATE TABLE 'proyecto_alumno' (
'proy_alum_id' int(4) UNSIGNED NOT NULL,
'proy_id' int(5) UNSIGNED NOT NULL,
'alum_id' int(9) NOT NULL
RESULT OF CONSULTATION IN ENROLLING STUDENT
Warning: Missing argument 1 for bd_alumno_opciones(), called in C:\xampp\htdocs\Sistema Automatizado de Registro y Control 2016\registro4.php on line 37 and defined in C:\xampp\htdocs\Sistema Automatizado de Registro y Control 2016\conexion.php on line 342
Notice: Undefined variable: proy_id_seleccionado in C:\xampp\htdocs\Sistema Automatizado de Registro y Control 2016\conexion.php on line 347
DESIRED RESULT
BY CERTAIN APPLY THE FUNCTION OF: Eduardo Fuentes and now it shows what I want but keeps saying that a variable is missing.
The line of code that gives error is the function that is above
REGISTRATION FORM:
<?php
include 'conexion.php';
$proy_id_seleccionado= 0;
$alumno = bd_alumno_opciones();
$proyecto = bd_proyecto_opciones();
<form id="frmIns" class="form-horizontal" method="POST" action="proc_inscripcion4.php" role="form">
<select class="form-control" name="proyecto" id="proyectos">
<?php foreach($proyecto as $i=>$proyecto_temp):?>
<option value="<?=$i?>"><?=$proyecto_temp?></option>
<?php endforeach; ?>
</select>
</div>
</div>
<div class="form-group">
<div class="control-label col-lg-2"></div>
<div class="col-lg-5">
<input type="hidden" name="proy_id" id="proy_id" readonly value="" />
</div>
</div>
<div class="form-group">
<label for="alumno" class="col-lg-2 control-label"><font size=3 color="red">*</font>Alumnos:</label>
<div class="col-lg-5">
<?php foreach($alumno as $i=>$alumno_temp): ?>
<div class="checkbox"><label>
<input type="checkbox" name="alum[]" id="alum_<?=$i?>" value="<?=$i?>"> <?=$alumno_temp?></label></div>
<?php endforeach; ?>
</div>
</div>
<div class="form-group">
<div class="col-lg-2"></div>
<div class="col-lg-5">
<button type="submit" class="btn btn-default">Guardar</button>
</div>
</div>