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)

Recommended Answers

Are the quizes defined somewhere in a table?

Jump to Post

All 3 Replies

Are the quizes defined somewhere in a table?

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>";

Can you show the table structures, and some data?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.21 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.