So habe ich eine SQL-Tabelle, die keine eindeutige Spalte hat. Ich muss es in einer Tabelle nach seiner ID anzeigen. Aber, wie ich schon sagte, die ID ist nicht eindeutigProbleme beim Anzeigen des Ergebnisses einer Auswahl in einer Tabelle
OBS¹: Beachten Sie, dass es darum geht, aus einer select-Anweisung
OBS²: der Benutzer-ID in der Auswahl von 0 bis zu 4-mal (nach id_questionario) erscheinen kann
Also, die Sache ist, wie werde ich eine Tabelle machen, die nur einmal user_id zeigen wird aber durch ihre Seite alle melhor_tentativa nach id_questionario anzeigen (beachten Sie, dass id_questionario nicht angezeigt werden soll, nur ich kann die melhor_tentativa in der richtigen Reihenfolge anzeigen)
Was ich verstehe ist, dass ich Linie habe s das sollten Spalten sein. Ich habe seit 2 Tagen versucht, das herauszufinden und stellt sich heraus, dass ich nicht kann. Dachte, dass es vielleicht vermissen sein, wie ich meine SQL-
gemacht Dies ist, wie die Tabelle
Dies ist, wie die SQL-Tabelle
Und unten ist sieht sieht der Code, den ich dafür gemacht habe
<?php
$count = 0;
$nota1 = 0;
$nota2 = 0;
$nota3 = 0;
$nota4 = 0;
?>
<?php
foreach($notas as $nota):
$total = 0;
?>
<tr>
<td><?php echo $nota['user_id']?></td>
<td>NULL</td>
<?php
if($nota['id_questionario']==1){
$nota1 = $nota['melhor_tentativa']*20;
}
?>
<td><?php echo $nota1 ?></td>
<?php
if($nota['id_questionario']==2){
$nota2 = $nota['melhor_tentativa']*20;
}
?>
<td><?php echo $nota2 ?></td>
<?php
if($nota['id_questionario']==3){
$nota3 = $nota['melhor_tentativa']*20;
}
?>
<td><?php echo $nota3 ?></td>
<?php
if($nota['id_questionario']==4){
$nota4 = $nota['melhor_tentativa']*20;
}
?>
<td><?php echo $nota4 ?></td>
<td><?php $total = ($nota1 + $nota2 + $nota3 + $nota4)/4; echo $total; ?></td>
</tr>
<?php $count++; ?>
<?php
endforeach;
echo $count;
?>
</table>
S.S: Ich weiß, dass total total falsch ist;)