Tengo un sitio desarrollado con php y mysql, en este tengo una página que tiene dos tablas html, en una tengo los profesionales que quiero agregar a un equipo, para ello tengo un botón en la última columna que al hacer clic me modifica un campo de la tabla de profesionales (seleccionado=1) y en la otra tabla muestro los registros de profesionales con seleccionado=1, pero cuando llego a 11 profesionales me quita el último y me agrega el otro, ¿cómo puedo solucionar este problema?
Este es el código del body de las tablas:
Código:
<p><font face="Verdana" size="2">Seleccione los profesionales a agregar al equipo</font></p>
<p style="text-align:right"><?php echo $resultados; ?></p>
<table class="Tabla1" id="Tabla1" cellpadding="2" cellspacing="2" style="border-collapse: collapse" width="100%">
<tr>
<th width="33%" align="center" height="1">Profesional</th>
<th width="33%" align="center" height="1">Foto</th>
<th width="34%" align="center" height="1">Agregar los profesionales al equipo</th>
</tr>
<?php
foreach($arrayProfesionales as $value) {
$id_profesionalG=$value["id_profesional"];
$profesionalG=utf8_encode($value["apellidos"]).", ".utf8_encode($value["nombres"]);
$imagenG = (!empty($value["imagen"])) ?
"<img style=\"border-radius: 50%;\" src=\"".$value["imagen"]."\" width=\"70\" height=\"70\" />" :
"<img style=\"border-radius: 50%;\" src=\"images/avatar.png\" width=\"70\" height=\"70\" />";
$agregarG=frm_button("agregar", "Agregar", "javascript:Agregar('$id_profesionalG')");
?>
<tr>
<td width="33%" align="center" height="1"><?php echo $profesionalG; ?></td>
<td width="33%" align="center" height="1"><?php echo $imagenG; ?></td>
<td width="34%" align="center" height="1"><?php echo $agregarG; ?></td>
</tr>
<?php
}
?>
</table>
<?php
echo $pagerNav;
$pagerPer = new PagerMySQL(1);
$sqlPer = "select * from perfiles where nombre in ('Profesional','Secretaria') order by nombre";
$opcionesPer=array("query"=>$sqlPer,"handle"=>$linkAuxiliar);
$arrayPerfiles = $pagerPer->getData($opcionesPer);
$cant_reg_per = count($arrayPerfiles);
$arrayPerfil = array();
if(!empty($cant_reg_per)){
foreach($arrayPerfiles as $value){
$id_perfilS = $value["id_perfil"];
$arrayPerfil[$id_perfilS] = utf8_encode($value["nombre"]);
}
}
?>
<br />
<?php
$pagerPro = new PagerMySQL(1);
$sqlP="select * from profesionales where seleccionado=1 order by apellidos, nombres";
$opciones=array("query"=>$sqlP,"handle"=>$linkAuxiliar);
$arraySeleccionados = $pagerPro->getData($opciones);
$cant_reg_s=count($arraySeleccionados);
if(!empty($cant_reg_s)){
?>
<p><font face="Verdana" size="2">Profesionales de este equipo</font></p>
<table class="Tabla1" cellpadding="2" cellspacing="2" style="border-collapse: collapse" width="100%">
<tr>
<th width="25%" align="center" height="1">Profesional</th>
<th width="25%" align="center" height="1">Foto</th>
<th width="25%" align="center" height="1">Perfil</th>
<th width="25%" align="center" height="1">Eliminar del equipo</th>
</tr>
<?php
foreach($arraySeleccionados as $value){
$id_profesionalG=$value["id_profesional"];
$profesionalG=utf8_encode($value["apellidos"]).", ".utf8_encode($value["nombres"]);
$imagenG = (!empty($value["imagen"])) ?
"<img style=\"border-radius: 50%;\" src=\"".$value["imagen"]."\" width=\"70\" height=\"70\" />" :
"<img style=\"border-radius: 50%;\" src=\"images/avatar.png\" width=\"70\" height=\"70\" />";
$sqlPE="select * from perfiles_equipos where id_equipo=? and id_profesional=?";
$resultPE = $linkAuxiliar->prepare($sqlPE);
$resultPE->bind_param('ii',$_SESSION["id_equipoI"],$id_profesionalG);
$id_perfilG = 0;
if($resultPE->execute()){
$resPE = $resultPE->get_result();
$rowPE = $resPE->fetch_assoc();
$resultPE->close();
$resPE->close();
$id_perfilG = $rowPE["id_perfil"];
}
$perfilG=frm_select("perfiles[]", "perfiles", $arrayPerfil, $id_perfilG);
$disabled=(!empty($id_perfilG)) ? "disabled=true" : "";
$eliminarG=frm_button("eliminar", "Eliminar profesional", "javascript:Eliminar('$id_profesionalG')", $disabled);
$hideG=frm_hide("hideProfesional[]", $id_profesionalG);
?>
<tr>
<td width="25%" align="center" height="1"><?php echo $profesionalG; ?></td>
<td width="25%" align="center" height="1"><?php echo $imagenG; ?></td>
<td width="25%" align="center" height="1"><?php echo $perfilG.$hideG; ?></td>
<td width="25%" align="center" height="1"><?php echo $eliminarG; ?></td>
</tr>
<?php
}
?>
<tr>
<td colspan="4" align="center" width="100%" height="25">
<input type="submit" name="guardar" value="Guardar" />
</td>
</tr>
</table>
<?php
}
?>