Foros del Web » Programando para Internet » PHP »

devolver mensaje al serviidor

Estas en el tema de devolver mensaje al serviidor en el foro de PHP en Foros del Web. hola a todos los del foro tengo la siguinte duda: tengo un formulario que en un objeto select muestra los nombres de alumnos, mediante un ...
  #1 (permalink)  
Antiguo 14/11/2007, 09:14
 
Fecha de Ingreso: mayo-2007
Mensajes: 413
Antigüedad: 16 años, 10 meses
Puntos: 0
Desacuerdo devolver mensaje al serviidor

hola a todos los del foro tengo la siguinte duda:

tengo un formulario que en un objeto select muestra los nombres de alumnos, mediante un boton, que preciono muestra puntajes, e ingreso otros para guardarlos y ponderarelos.

el problema se presenta cuando me posisiono en algun alumno que estan en el objeto select, presiono el boton para mostrar puntajes e ingreso otros y guardo, luego me posisiono en otro alumno, pero no presiono el boton para que muestre sus datos, guardando encima los puntajes del postulanter anterior. quedando como concecuencia 2 alumnos con el mismo apellido y mismo puntaje que se puede visualizar en los reportes.

la idea es poder evitar eso ..ya sea mandando un mensaje diciendo que tiene puntaje ya ese alumno u otra sugerencia ......ojala puedan ayudarme y me hayan entendido...gracias desde ya.....
__________________
Los que Saben....no Saben lo que Saben
  #2 (permalink)  
Antiguo 14/11/2007, 09:42
Avatar de kaninox  
Fecha de Ingreso: septiembre-2005
Ubicación: In my House
Mensajes: 3.597
Antigüedad: 18 años, 6 meses
Puntos: 49
Re: devolver mensaje al serviidor

codigo amigo para ver en que falla
__________________
Gokuh Salvo al mundo. PUNTO!!!!
  #3 (permalink)  
Antiguo 14/11/2007, 11:16
 
Fecha de Ingreso: mayo-2007
Mensajes: 413
Antigüedad: 16 años, 10 meses
Puntos: 0
Re: devolver mensaje al serviidor


<?
//////// Valido existencia de Datos en Test_Selección *****************

if ($datos==1) {
$CORR=$select;

$sql="SELECT TS_TRES, TS_TRMA, TS_TRVE, TS_TRME FROM TEST_SELECCION";
$query=@mysql_query($sql, $dblink);
while ($row = mysql_fetch_array($query))
{
$TS_TRES = $row['TS_TRES'];
$TS_TRMA = $row['TS_TRMA'];
$TS_TRVE = $row['TS_TRVE'];
$TS_TRME = $row['TS_TRME'];

$ComprobacionBD=($TS_TRES + $TS_TRMA + $TS_TRVE + $TS_TRME);
if ($ComprobacionBD==0) {
$flag=0;
$DESV_EST_web=0;
}
elseif ($ComprobacionBD!=0) {
$flag=1;
}
}
}
?>

<?
//si hay postulante seleccionado y no hay test - primer caso****
if (($datos==1) and ($flag==0)) {

$PROD_UNO=($TP_PPSZ*$FTS_PONDERACION_TP);
$PROD_DOSa=(($nota_tres*$FTS_TRES)+($nota_trma*$FT S_TRMA)+($nota_trve*$FTS_TRVE)+($nota_trme*$FTS_TR ME));
$PROD_DOS=bcadd($PROD_DOSa, 0, 3);

$PROD_DOS_POR_FACTOR_S=($PROD_DOS*$FTS_PONDERACION _TS);
$PROD_DOS_POR_EMP=($PROD_DOS_POR_FACTOR_S*$EMP);
}

if (($flag==0) AND ($datos==1) AND ($nota_tres!="") AND ($nota_trma!="") AND ($nota_trve!="") AND ($nota_trme!="") AND ($nota_tpers!="")) {
echo '<td width="37%"><b><font face="Tahoma" color="#0000FF" size="1">TPERS</font></b></td>';
echo '<td><div align="center"><font face="Tahoma" size="2" color="#000000">'.$nota_tpers.'</font></div></td>';
echo '<td bgcolor="#99ffff"><div align="center"><font face="Tahoma" size="2" color="#000000">0</font></div></td><tr>';
$PTJE_FINAL_TSa=($PROD_UNO)+($PROD_DOS_POR_EMP)+($ nota_tpers * $DESV_EST_web);
$PTJE_FINAL_TS=bcadd($PTJE_FINAL_TSa, 0, 3);

}

?>

<?

if (((isset($boton_submit))) and ($datos==1) and ($flag==0) AND ($nota_tres!="") AND ($nota_trma!="") AND ($nota_trve!="") AND ($nota_trme!="") AND ($nota_tpers!="")) {

$sql4="INSERT INTO TEST_SELECCION VALUES ('$CORR', '', '2', '$RUTZ', now(), '$nota_tres', '$nota_trma', '$nota_trve', '$nota_trme', '$PROD_DOS', '$nota_tpers', '$DESV_EST_web', '$PTJE_FINAL_TS', '0')";
$query4=@mysql_query($sql4, $dblink);

$par1=($TP_PPSZ * $FTS_PONDERACION_TP);
$par2=$PROD_DOS_POR_FACTOR_S;
$suma_pares=bcadd($par1, $par2, 4);
$sql222="INSERT INTO ALM_PARES VALUES ('$CORR', '$suma_pares')";
$query222=@mysql_query($sql222, $dblink);
}

elseif (((isset($boton_submit))) and ($datos==1) and ($flag==1) AND ($nota_tres!="") AND ($nota_trma!="") AND ($nota_trve!="") AND ($nota_trme!="") AND ($nota_tpers!="")) {

$sql5="INSERT INTO TEST_SELECCION VALUES ('$CORR', '', '2', '$RUTZ', now(), '$nota_tres', '$nota_trma', '$nota_trve', '$nota_trme', '5', '$nota_tpers', '10', '15', '0')";
$query5=@mysql_query($sql5, $dblink);
$ins=1;

}
elseif (((isset($boton_submit))) and ($datos==1) and (($nota_tres=="") OR ($nota_trma=="") OR ($nota_trve=="") OR ($nota_trme==""))) {

?>
<script>
alert('Debe Ingresar Notas de Test´s');
</script>
<?
}
elseif(((isset($boton_submit))) and ($datos==0)) {
?>
<script>
alert('Debe seleccionar postulante y datos PPS');
</script>
<?
}

?>
<?
if ($ins=='1') {

if (($ComprobacionBD!=0) and ($flag==1)) {

$sql25="SELECT TS.TS_ID, TS.TS_TRES, TS.TS_TRMA, TS.TS_TRVE, TS.TS_TRME, TP.TP_PPS FROM TEST_PRESELECCION22 AS TP, TEST_SELECCION AS TS WHERE ((TS.TS_ID='$CORR') AND (TP.TP_ID='$CORR') AND (TS.TS_ID=TP.TP_ID))";
$query25=@mysql_query($sql25, $dblink);
while ($row = mysql_fetch_array($query25))
{
$TS_ID = $row['TS_ID'];
$almacena_ID = $row['TS_ID'];
$TP_PPS = $row['TP_PPS'];
$TS_TRES = $row['TS_TRES'];
$TS_TRMA = $row['TS_TRMA'];
$TS_TRVE = $row['TS_TRVE'];
$TS_TRME = $row['TS_TRME'];
$par1=($TP_PPS * $FTS_PONDERACION_TP);
$par2=((($TS_TRES*$FTS_TRES) + ($TS_TRMA*$FTS_TRMA) + ($TS_TRVE*$FTS_TRVE) + ($TS_TRME*$FTS_TRME))*($FTS_PONDERACION_TS));
$suma_pares=bcadd($par1, $par2, 4);

$sql22="INSERT INTO ALM_PARES VALUES ('$almacena_ID', '$suma_pares')";
$query22=@mysql_query($sql22, $dblink);

}
}

if (($ComprobacionBD!=0) and ($flag==1)) {
//****Aquí calculo la DesvEstandar con AP_SUMA - todos los Postulantes
$sumatoria=0;
$cont=0;
$sql20="SELECT AP_SUMA FROM ALM_PARES";
$query20=@mysql_query($sql20, $dblink);
while ($row = mysql_fetch_array($query20))
{
$AP_SUMA = $row['AP_SUMA'];
$sumatoria=(($sumatoria) + ($AP_SUMA));
$cont=($cont+1);
}

if ($cont!='0') {
$Promedio=bcdiv($sumatoria, $cont, 4);
}
}
if (($ComprobacionBD!=0) and ($flag==1)) {
$ConRaiz=0;
$sql333="SELECT AP_SUMA FROM ALM_PARES";
$query333=@mysql_query($sql333, $dblink);
while ($row = mysql_fetch_array($query333))
{
$AP_SUMA = $row['AP_SUMA'];

$ALM_menos_PromFun=bcsub($AP_SUMA, $Promedio, 4);
//printf("ES_menos_PromFun = ");
//printf($ES_menos_PromFun);

$ALM_al_Cuad=bcpow($ALM_menos_PromFun, 2, 4);
//printf("ES_al_Cuad = ");
//printf($ES_al_Cuad);


$ConRaiz=(($ConRaiz) + ($ALM_al_Cuad));
}
$cont_menos_uno=($cont - 1);
if ($cont_menos_uno!='0') {
$ConRaiz_div=bcdiv($ConRaiz, $cont_menos_uno, 4);

$DESV_EST=bcsqrt($ConRaiz_div, 4);
//echo "DESV: $DESV_EST <br>";
}
}

//Aquí calculo el Puntaje de "ese" Postulante
if (($ComprobacionBD!=0) and ($flag==1)) {

$sql444 = "SELECT DISTINCT PO.PATERNO, PO.MATERNO, PO.NOMBRES, PO.RUT, PO.DV, PO.TIENEPATROCINIO, TP.TP_PPS, TS.TS_ID, TS.TS_TRES, TS.TS_TRMA, TS.TS_TRVE, TS.TS_TRME, TS.TS_N FROM POSTULANTE AS PO, TEST_PRESELECCION22 AS TP, TEST_SELECCION AS TS WHERE ((TP.TP_IDENPOST=TS.TS_IDENTPOST) AND (PO.RUT=TP.TP_IDENPOST) AND (TS.TS_ID='$CORR') AND (TP.TP_ID=TS.TS_ID))";
$query444 = @mysql_query($sql444, $dblink);
while ($row = mysql_fetch_array($query444))
{
$TS_ID = $row['TS_ID'];
$almacenaID30 = $row['TS_ID'];
$PATERNOZ = $row['PATERNO'];
$MATERNOZ = $row['MATERNO'];
$NOMBRESZ = $row['NOMBRES'];
$RUTZ = $row['RUT'];
$DVZ = $row['DV'];
$TP_PPSZ30 = $row['TP_PPS'];
$TIENEPATROCINIOZ30 = $row['TIENEPATROCINIO'];
$TS_TRES30 = $row['TS_TRES'];
$TS_TRMA30 = $row['TS_TRMA'];
$TS_TRVE30 = $row['TS_TRVE'];
$TS_TRME30 = $row['TS_TRME'];
$TS_N30 = $row['TS_N'];
$TS_PTS30 = $row['TS_PTS'];
if ($TIENEPATROCINIOZ30=='0') {
$EMP30=$FTS_SINPATRO;
}

elseif ($TIENEPATROCINIOZ30=='1') {
$EMP30=$FTS_CONPATRO;
}

$PROD_UNO=($TP_PPSZ30*$FTS_PONDERACION_TP);
//echo "PROD_UNO:$PROD_UNO";
$PROD_DOSa=(($TS_TRES30*$FTS_TRES)+($TS_TRMA30*$FT S_TRMA)+($TS_TRVE30*$FTS_TRVE)+($TS_TRME30*$FTS_TR ME));
$PROD_DOS=bcadd($PROD_DOSa, 0, 3);
//echo "PROD_DOS: $PROD_DOS";

$PROD_DOS_POR_FACTOR_S=($PROD_DOS*$FTS_PONDERACION _TS);
//echo "PROD_DOS_POR_FACTOR_S**: $PROD_DOS_POR_FACTOR_S";
$PROD_DOS_POR_EMP=($PROD_DOS_POR_FACTOR_S*$EMP30);
//echo "PROD_DOS_POR_EMP: $PROD_DOS_POR_EMP";
//echo "TS_N:$TS_N";
$PTJE_FINAL_TSa=($PROD_UNO)+($PROD_DOS_POR_EMP)+($ TS_N30 * $DESV_EST);
$PTJE_FINAL_TS=bcadd($PTJE_FINAL_TSa, 0, 3);
//echo "PTJE_FINAL_TS: $PTJE_FINAL_TS <br>\n";
$sql5555 = "UPDATE TEST_SELECCION SET TS_PTS='$PROD_DOS', TS_DESV='$DESV_EST', TS_PS='$PTJE_FINAL_TS' WHERE (TS_ID='$almacenaID30')";
$query5555 = @mysql_query($sql5555, $dblink);
}
}

}
?>
<?
if (($flag==1) AND ($datos==1) AND ($nota_tres!="") AND ($nota_trma!="") AND ($nota_trve!="") AND ($nota_trme!="") AND ($nota_tpers!="")) {
echo '<td width="37%"><b><font face="Tahoma" color="#0000FF" size="1">TPERS</font></b></td>';
echo '<td><div align="center"><font face="Tahoma" size="2" color="#000000">'.$nota_tpers.'</font></div></td>';
echo '<td bgcolor="#99ffff"><div align="center"><font face="Tahoma" size="2" color="#000000">'.$DESV_EST.'</font></div></td><tr>';
$PTJE_FINAL_TSa=($PROD_UNO)+($PROD_DOS_POR_EMP)+($ TS_N30 * $DESV_EST);
$PTJE_FINAL_TS=bcadd($PTJE_FINAL_TSa, 0, 3);

}

if (($nota_tres!="") AND ($nota_trma!="") AND ($nota_trve!="") AND ($nota_trme!="") AND ($PATERNOZ!="")) {
echo '<td width="37%" bgcolor="#99ccff"><div align="center"><font face="Tahoma" color="#000000" size="1"><b>TestSelección</b></font></div></td>';
echo '<td width="28%" bgcolor="#99ccff"><div align="center"><font face="Tahoma" size="2" color="#000000">'.$PROD_DOS.'</font></div></td>';
echo '<td bgcolor="#99CC99" width="35%"><div align="center"><div align="center"><font face="Tahoma" size="2" color="#000000">'.$PTJE_FINAL_TS.'</font></div></td>';
}
?>[/PHP]
__________________
Los que Saben....no Saben lo que Saben
  #4 (permalink)  
Antiguo 14/11/2007, 11:20
 
Fecha de Ingreso: mayo-2007
Mensajes: 413
Antigüedad: 16 años, 10 meses
Puntos: 0
Re: devolver mensaje al serviidor

resumi el codig porque era mucho, aca parte cuando me posisiono ya en el select y extraigo puntajes para luego insertar otros y guardar

no se si podras ayudarme gracias
__________________
Los que Saben....no Saben lo que Saben
  #5 (permalink)  
Antiguo 14/11/2007, 13:22
 
Fecha de Ingreso: mayo-2007
Mensajes: 413
Antigüedad: 16 años, 10 meses
Puntos: 0
Re: devolver mensaje al serviidor

y nadie q me oriente ??
__________________
Los que Saben....no Saben lo que Saben
  #6 (permalink)  
Antiguo 18/11/2007, 10:56
Avatar de kaninox  
Fecha de Ingreso: septiembre-2005
Ubicación: In my House
Mensajes: 3.597
Antigüedad: 18 años, 6 meses
Puntos: 49
Re: devolver mensaje al serviidor

andales podrias poner solo tu codigo :P en la parte que segun tu falla por que hay varias variables que no entiendo para que sirven y demas, pero resumiendo supongo es algun problema de Update, cuando haces el cambio te lo transfiere a todos los alumnos? es eso o me equivoco, es que veo cosas como

$sql5555 = "UPDATE TEST_SELECCION SET TS_PTS='$PROD_DOS', TS_DESV='$DESV_EST', TS_PS='$PTJE_FINAL_TS' WHERE (TS_ID='$almacenaID30')";

y por ejemplo $almacenaID30 :P no se de donde sale aparte no especificas si viene por POST o GET deberias poner $_POST[almacenaID30]

por ej...
ahora bien solo debe ser error de planteamiento, mira cuando extraes haces un select y buscas y hay o no datos correcto, si hay muestras los que hay si no no muestras nada, ahora bien, esto deberia actualizarse en el WHERE del UPDATE, con el rut o id del alumnos, que supondre es almacenaID30 :/ asi solo actualizamos 1 alumno, bueno revisa tu codigo y antes de hacer actualizaciones imprime tus salidas para ver que envias ;)
__________________
Gokuh Salvo al mundo. PUNTO!!!!
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 19:42.