0

I have quiz ID(Q1 for example) and below is the number of items in that quiz. My problem is, I need to display a dash when query cannot find a record in my database, if there is a record it will show up and the missing records will be filled with "-". By the way, "a" in the scores is unnecessary. Responses will be much appreciated, thanks in advance!

$sql3 = "SELECT score FROM quiz_score_tbl WHERE username = '$stud_no'";
$result3 = mysql_query($sql3);
$checker3 = mysql_num_rows($result3);
while($row3 = mysql_fetch_array($result3))
{
$score = $row3['score'];

echo"<td> $score a</td>";
if ($score == "" OR $score == NULL OR $checker3 == 0)
{
echo"<td>-</td>";
}
}
Attachments image1.png 10.72 KB image2.png 13.16 KB
2
Contributors
3
Replies
8
Views
4 Years
Discussion Span
Last Post by pritaeas
0

Yes, I have 2 tables in my database, quiz_tbl and quiz_score_tbl.
The code above is the continuation of this code.

$sql2 = "SELECT quiz_id,items FROM quiz_tbl WHERE section LIKE 'A%'";
    $result2 = mysql_query($sql2);
    while($row2 = mysql_fetch_array($result2)){
    $q_id = $row2['quiz_id'];
    $q_items = $row2['items'];
    echo"<td align='center'>Q".$q_id."<br>".$q_items."</td>";
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.