Dos recomendaciones, primero:
Código PHP:
Ver original<td>"; if($row2['ob1'] != ""){ echo "<input type='checkbox' name=c1 value=1 >"; } else{ echo ""; } echo "</td>
<td>"; if($row2['ob2'] != ""){ echo "<input type='checkbox' name=c2 value=1 >"; } else{ echo ""; } echo "</td>
<td>"; if($row2['ob3'] != ""){ echo "<input type='checkbox' name=c3 value=1 >"; } else{ echo ""; } echo "</td>
<td>"; if($row2['ob4'] != ""){ echo "<input type='checkbox' name=c4 value=1 >"; } else{ echo ""; } echo "</td>
<td>"; if($row2['ob5'] != ""){ echo "<input type='checkbox' name=c5 value=1 >"; } else{ echo ""; } echo "</td>
<td>"; if($row2['ob6'] != ""){ echo "<input type='checkbox' name=c6 value=1 >"; } else{ echo ""; } echo "</td>
<td>"; if($row2['ob7'] != ""){ echo "<input type='checkbox' name=c7 value=1 >"; } else{ echo ""; } echo "</td>
<td>"; if($row2['ob8'] != ""){ echo "<input type='checkbox' name=c8 value=1 >"; } else{ echo ""; } echo "</td>
<td>"; if($row2['ob9'] != ""){ echo "<input type='checkbox' name=c9 value=1 >"; } else{ echo ""; } echo "</td>
<td>"; if($row2['ob10'] != ""){ echo "<input type='checkbox' name=c10 value=1 >"; } else{ echo ""; } echo "</td>
<td>"; if($row2['ob11'] != ""){ echo "<input type='checkbox' name=c11 value=1 >"; } else{ echo ""; } echo "</td>
<td>"; if($row2['ob12'] != ""){ echo "<input type='checkbox' name=c12 value=1 >"; } else{ echo ""; } echo "</td>
<td>"; if($row2['ob13'] != ""){ echo "<input type='checkbox' name=c13 value=1 >"; } else{ echo ""; } echo "</td>
<td>"; if($row2['ob14'] != ""){ echo "<input type='checkbox' name=c14 value=1 >"; } else{ echo ""; } echo "</td>
En vez de eso, por tema de
recursos (me parece, no estoy seguro) quizás te convenga convertirlo a :
Código PHP:
Ver originalfor($i=1;$i<14;$i++){
$numOb = 'ob' . $i;
echo "<td">;
if($row[$numOb] != ""){
echo "<input type='checkbox' name=c".$i." value=1 >";
}else{
echo "";
}
echo "</td>"
}
Mientras que a esto:
Te convendría de esta forma:
Código PHP:
Ver original<?
include ("conexion.php");
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
# post
$c1 = $_POST['c1'];
$c2 = $_POST['c2'];
$c3 = $_POST['c3'];
$c4 = $_POST['c4'];
$c5 = $_POST['c5'];
$c6 = $_POST['c6'];
$c7 = $_POST['c7'];
$c8 = $_POST['c8'];
$c9 = $_POST['c9'];
$c10 = $_POST['c10'];
$c11 = $_POST['c11'];
$c12 = $_POST['c12'];
$c13 = $_POST['c13'];
$c14 = $_POST['c14'];
$nota3 = $_POST['nota3'];
$val = $_POST['val'];
$juicio = $_POST['juicio'];
//////////////////////////////////////////////////////////////////////////////////////////////////////////////
# chechkbox
if( $c1 != "") {
if( $c1 == "1" ) {
$c1 = "F";
} else {
$c1 = "D";
}
}
if( $c2 != "") {
if( $c2 == "1" ) {
$c2 = "F";
} else {
$c2 = "D";
}
}
if( $c3 != "") {
if( $c3 == "1" ) {
$c3 = "F";
} else {
$c3 = "D";
}
}
if( $c4 != "") {
if( $c4 == "1" ) {
$c4 = "F";
} else {
$c4 = "D";
}
}
if( $c5 != "") {
if( $c5 == "1" ) {
$c5 = "F";
} else {
$c5 = "D";
}
}
if( $c6 != "") {
if( $c6 == "1" ) {
$c6 = "F";
} else {
$c6 = "D";
}
}
if( $c7 != "") {
if( $c7 == "1" ) {
$c7 = "F";
} else {
$c7 = "D";
}
}
if( $c8 != "") {
if( $c8 == "1" ) {
$c8 = "F";
} else {
$c8 = "D";
}
}
if( $c9 != "") {
if( $c9 == "1" ) {
$c9 = "F";
} else {
$c9 = "D";
}
}
if( $c10 != "") {
if( $c10 == "1" ) {
$c10 = "F";
} else {
$c10 = "D";
}
}
if( $c11 != "") {
if( $c11 == "1" ) {
$c11 = "F";
} else {
$c11 = "D";
}
}
if( $c12 != "") {
if( $c12 == "1" ) {
$c12 = "F";
} else {
$c12 = "D";
}
}
if( $c13 != "") {
if( $c13 == "1" ) {
$c13 = "F";
} else {
$c13 = "D";
}
}
if( $c14 != "") {
if( $c14 == "1" ) {
$c14 = "F";
} else {
$c14 = "D";
}
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
# valoracion
if( $nota3 != "")
if($nota3<3.0){
$val="bajo";
}
if($nota3>=3.0 && $nota3<=3.6){
$val="basico";
}
if($nota3>=3.7 && $nota3<=4.3){
$val="alto";
}
if($nota3>=4.4){
$val="superior";
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
# update
$sql = "UPDATE SEXTO_A_MAT SET c1='$c1', c2='$c2', c3='$c3', c4='$c4', c5='$c5', c6='$c6', c7='$c7', c8='$c8', c9='$c9', c10='$c10', c11='$c11', c12='$c12', c13='$c13', c14='$c14', nota3='$nota3', val='$val' , juicio='$juicio' WHERE id=1";
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
echo "<center> datos insertados con exito </center>";
?>
Lo reemplazaría por esto:
Código PHP:
Ver original<?php
include("conexion.php");
/* Incluir archivo conexion */
$c1 = $_POST['c1'];
$c2 = $_POST['c2'];
$c3 = $_POST['c3'];
$c4 = $_POST['c4'];
$c5 = $_POST['c5'];
$c6 = $_POST['c6'];
$c7 = $_POST['c7'];
$c8 = $_POST['c8'];
$c9 = $_POST['c9'];
$c10 = $_POST['c10'];
$c11 = $_POST['c11'];
$c12 = $_POST['c12'];
$c13 = $_POST['c13'];
$c14 = $_POST['c14'];
$nota3 = $_POST['nota3'];
$val = $_POST['val'];
$juicio = $_POST['juicio'];
/* Obteniendo valores de CheckBox */
$array = array($c1,$c2,$c3,$c4,$c5,$c6,$c7,$c8,$c9,$c10,$c11,$c12,$c13,$c14); $count_array = count($array);
for($i=0;$i<$count_array;$i++){
if($array[$i] != "" && $array[$i] == "1"){
$c_$i = "F";
}else{
$c_$i = "D";
}
}
/* Valoraciones */
if($nota3 != "" && $nota3<3.0){
$val="bajo";
}elseif(($nota3 !="") && $nota3>=3.0 && $nota3<=3.6){
$val = "basico";
}elseif(($nota3 !="") && $nota3>=3.7 && $nota3<=4.3){
$val = "alto";
}elseif(($nota3 != "") && $nota3>=4.4){
$val = "superior";
}
/* Consulta MySQL */
$sql = "UPDATE SEXTO_A_MAT SET c1='$c_1',c2='$c_2',c3='$c_3',c4='$c_4',c5='$c_5',c6='$c_6',c7='$c_7',c8='$c_8',c9='$c_9',c10='$c_10',c11='$c_11',c12='$c_12',c13='$c_13',c14='$c_14',nota3='$nota3',val='$val',juicio='$juicio' WHERE id=1";
/* Aviso de actualización correcta */
echo "<center> Datos insertados correctamente </center>";
?>
Despues me contás como te fue amigo.
Un saludo