La idea es que tu aprendas a hacer las cosas por tu cuenta porque si se te dan las cosas hechas va a ser más difícil que aprendas, de todas formas aquí está el código, trata de analizarlo y aprender cómo se hace:
Código PHP:
Ver original<!DOCTYPE html>
<html lang="es">
<head>
<title>Prueba</title>
<?php
require_once("includes/connection.php");
if (isset($_GET['tematicasId']) && !isset($_POST['submit'])) {
$aux=$_GET['tematicasId'];
if ($aux=='1')
{
$sTematica="Matematicas";
$show='0';
}
else
{
echo "Se ha especificado una tematica no valida";
}
}
else
{
if (isset($_POST['submit'])) {
$sTematica="Matematicas"; //Este se debe obtener por un switch o if comparando tematicasid
$aux='1'; //Este se debe pasar por GET
$respuestas=$_POST['respuesta'];
$show='1';
}
else
{
echo "No se ha especificado una tematica de la evaluacion";
}
}
?>
</head>
<body>
<?php
$sql = "SELECT * FROM Evaluaciones WHERE tematicasId='".$aux."' AND ID_eval='1'";
?>
<?php echo "<h1>Evaluacion de ".$sTematica."</h1><br>";?>
<table width="615" border="1">
<form action='' method='post'>
<?php
if ($show=='0')
{
if ($iNumReg>0)
{
$i = 0;
{
$dbpregunta = $rowEmp['evaluacionPregunta'];
$dbR1=$rowEmp['evaluacionR1'];
$dbR2=$rowEmp['evaluacionR2'];
$dbR3=$rowEmp['evaluacionR3'];
echo "<tr>";
echo "<td colspan='3'>Pregunta: ".$dbpregunta."</td>";
echo "</tr>";
echo "<tr>";
echo "<td width='38'>Opcion</td>";
echo "<td width='486'>Respuesta</td>";
echo "<td width='69'>Correcta</td>";
echo "</tr>";
echo "<tr>";
echo "<td>a</td>";
echo "<td>".$dbR1."</td>";
echo "<td><input name='respuesta[".$i."]' type='radio' value='1'></td>";
echo "</tr>";
echo "<tr>";
echo "<td>b</td>";
echo "<td>".$dbR2."</td>";
echo "<td><input name='respuesta[".$i."]' type='radio' value='2'></td>";
echo "</tr>";
echo "<tr>";
echo "<td>c</td>";
echo "<td>".$dbR3."</td>";
echo "<td><input name='respuesta[".$i."]' type='radio' value='3'></td>";
echo "</tr>";
$i += 1;
}
}
}
else
{
if ($iNumReg>0)
{
$i = 0;
{
$dbpregunta = $rowEmp['evaluacionPregunta'];
$dbR1=$rowEmp['evaluacionR1'];
$dbR2=$rowEmp['evaluacionR2'];
$dbR3=$rowEmp['evaluacionR3'];
$dbcorrecta=$rowEmp['Correcta'];
echo "<tr>";
echo "<td colspan='3'>Pregunta: ".$dbpregunta."</td>";
echo "</tr>";
echo "<tr>";
echo "<td width='38'>Opcion</td>";
echo "<td width='486'>Respuesta</td>";
echo "<td width='69'>Resultado</td>";
echo "</tr>";
echo "<tr>";
echo "<td>a</td>";
if ($respuestas[$i]=='1')
{
echo "<td style='background-color: beige;'>".$dbR1." (Seleccionada)</td>";
}
else
{
echo "<td>".$dbR1."</td>";
}
if ($respuestas[$i]==$dbcorrecta)
{
echo "<td style='background-color: aquamarine;' rowspan='3'>Bien</td>";
}
else
{
echo "<td style='background-color: salmon;'rowspan='3'>Mal</td>";
}
echo "</tr>";
echo "<tr>";
echo "<td>b</td>";
if ($respuestas[$i]=='2')
{
echo "<td style='background-color: beige;'>".$dbR2." (Seleccionada)</td>";
}
else
{
echo "<td>".$dbR2."</td>";
}
echo "</tr>";
echo "<tr>";
echo "<td>c</td>";
if ($respuestas[$i]=='3')
{
echo "<td style='background-color: beige;'>".$dbR3." (Seleccionada)</td>";
}
else
{
echo "<td>".$dbR3."</td>";
}
echo "</tr>";
$i += 1;
}
}
}
echo "<tr>";
if ($show=='0')
{
echo "<td><br><br></td><td style='text-align: center;'><input name='submit' type='submit' value='Enviar evaluacion'></td>";
}
else
{
echo "<td><br><br></td><td style='text-align: center;'><a href='prueba.php?tematicasId=1'>Volver</a></td>";
}
echo "</tr>";
?>
</form>
</table>
</body>
</html>
Espero te sea de ayuda, de todas formas tienes que aprender a hacerlo por tu cuenta.