Я пытаюсь организовать свои таблицы в соответствии с годом (ano).
На моей таблице в столбце Ano у меня есть 1º, 2º и 3º. Я хочу 2º Ano с другими строками, чтобы он был разделен как другая таблица под таблицей, которая будет содержать данные 1º Ano. С другой стороны, каждая таблица будет иметь более 9 столбцов. Как я могу вычислить сумму шести (6) первых чисел и отобразить их? Не то чтобы общая сумма будет зависеть от данных, которые будут иметь каждая таблица. Каждая таблица будет иметь свою собственную сумму.
Больше объяснений
мой код
<?php
$id = @$_POST ['id'];
$id2 = @$_POST ['id2'];
$s = @pg_escape_string(str_replace(";","<",$s));
$con =@ pg_connect ("port=5432 host=localhost dbname=postgres user=postgres password=a");
if ($con==NULL){
echo "Cannot connect to database or No Database found.";
exit (0);
}
if(strlen($s)>0){
$sql="select codigo, disciplina, legenda, ano, r, t, tp, pl, ts, total, ms, diurno, contacto, pos_laboral, contacto2 from cursosprogramas where codigocurso='$grdid' order by ano;";
} else{
//echo '<table border=1 style="font-size:12px;" bgcolor=white width=950px><tr>';
$sql= "select codigo, disciplina, legenda, ano, r, t, tp, pl, ts, total, ms, diurno, contacto, pos_laboral, contacto2 from cursosprogramas where codigocurso='$grdid' order by ano;";
}
//echo $sql."<br>";
$res = @pg_query ($con, $sql);
if ($res == NULL){
echo "Query failed.";
exit (0);
}
echo '<table border=1 style="font-size:12px;" bgcolor=white width=900px><tr>';
$res2=pg_query($con, $sql);
echo "<tr><td colspan=11 align=center><b color=green>Curso\Licenciatura <b> $curso ";
echo '<tr><td align=center width=70px style="color:green;"><b>Código<td align=center width=200px style="color:green;"><b>Disciplina<td align=center width=70px style="color:green;"><b>Legenda<td align=center width=200px style="color:green;"><b>Ano<td align=center width=20px style="color:green;"><b>R<td align=center width=20px style="color:green;"><b>T<td align=center width=20px style="color:green;"><b>TP<td align=center width=20px style="color:green;"><b>PL<td align=center width=20px style="color:green;"><b>TS<td align=center width=40px style="color:green;"><b>Total<td align=center width=20px style="color:green;"><b>MS<td align=center width=300px style="color:green;"><b>Diurno<td align=center width=70px style="color:green;"><b>Contacto<td align=center width=300px style="color:green;"><b>Pós-Laboral<td align=center style="color:green;"><b>Contacto';
for ($i=0; $i< pg_numrows ($res);$i++){
echo '<tr align=center bgcolor=white>';
for ($j=0; $j <pg_numfields($res);$j++){
echo "<td>".pg_result($res, $i,$j)."";
}
}
echo "</table>";
?>