I put a test to some students, I have a software so that they enter with their username and password, they choose one of 5 answers that there is in the page and already that is uploaded to a database.
The tables that I have in the database are: One that has the 5 answers, another that has the information of the students, and another that relates the Student_ID with the Id_Response.
At this moment they are already voting, but the answers that have 0 elections do not appear to me. How do I print the entire table and the answers that have 0 choices?
<?php
include 'Conexion.php';
//$sql = mysql_query("SELECT * FROM 'respuestas' WHERE 'Id_Respuesta'= 3 ORDER BY 'Id_Relacion' ASC",$con_mysql);
//$cuenta = mysql_num_rows($sql);
//echo $cuenta;
$sql = "SELECT * FROM 'respuestas' WHERE 'Id_Respuesta'= 1 ORDER BY 'Id_Relacion' ASC";
$res = mysql_query($sql,$con_mysql);
$row = mysql_num_rows($res);
$sql1 = "SELECT * FROM 'respuestas' WHERE 'Id_Respuesta'= 2 ORDER BY 'Id_Relacion' ASC";
$res1 = mysql_query($sql1,$con_mysql);
$row1 = mysql_num_rows($res1);
$sql2 = "SELECT * FROM 'respuestas' WHERE 'Id_Respuesta'= 3 ORDER BY 'Id_Relacion' ASC";
$res2 = mysql_query($sql2,$con_mysql);
$row2 = mysql_num_rows($res2);
$sql3 = "SELECT * FROM 'respuestas' WHERE 'Id_Respuesta'= 4 ORDER BY 'Id_Relacion' ASC";
$res3 = mysql_query($sql3,$con_mysql);
$row3 = mysql_num_rows($res3);
$sql4 = "SELECT * FROM 'respuestas' WHERE 'Id_Respuesta'= 5 ORDER BY 'Id_Relacion' ASC";
$res4 = mysql_query($sql4,$con_mysql);
$row4 = mysql_num_rows($res4);
echo '<table border="1">
<tr>
<td colspan="2">Total de votos</td>
</tr>
<tr>
<td>Candidatos</td>
<td>Votos</td>
</tr>';
if(($row = mysql_num_rows($res)) && ($row1 = mysql_num_rows($res1)) && ($row2 = mysql_num_rows($res2)) && ($row3 = mysql_num_rows($res3)) && ($row4 = mysql_num_rows($res4)))
{
echo '<tr>
<td> Messi </td>
<td> '.$row.' </td>
</tr>
<tr>
<td> Cristiano Ronaldo </td>
<td> '.$row1.' </td>
</tr>
<tr>
<td> David Ospina </td>
<td> '.$row2.' </td></tr>
<tr>
<td> Arturo Vidal </td>
<td> '.$row3.' </td></tr>
<tr>
<td> Alexis Sanchez </td>
<td> '.$row4.' </td></tr>
</table>';
}
?>
I hope that with this little information you can help me.