Jump to content

Recommended Posts

I have the following code which will display a quiz result as an image representing pass or fail on a student's report page. The student may have attempted several different quizzes and sometimes repeated a quiz several times. As a result, the code displays every attempt and every result. Is there some way that I can have the code display as follows;

 

        1. Display only the most recent successful quiz for each quizTitle, (in other words display a pass image for a successful quiz, but no duplicate pass images if the same quiz has been passed more than once.)

        2. If a quiz has been failed, there is a fail image displayed. If a student makes several unsuccessful attempts, a fail image is displayed for each fail. I would like the code to cease displaying a fail image as soon as a quiz has been returned to and successfully passed. In other words, instead of a student accumulating several fail images, just one successful attempt will cause all previous fail images to stop being displayed.

 

I hope someone can make sense of this and suggest a solution.

                <?php
$query1 = mysql_query("SELECT DISTINCT quizTitle, userId, passState, userScore, totalScore, userDate FROM quiz WHERE managerId = '$managerId' AND userId = '$userId' ORDER BY quizTitle ASC");

while ($row = mysql_fetch_array($query1)){ 
	echo "{$row['quizTitle']} <br />\n"; 
    	echo "{$row['userDate']} <br />\n";
	if ("{$row['passState']}" == 1) {echo "<img src='pass.png' /><br />\n";}
	if ("{$row['passState']}" == 0) {echo "<img src='fail.png' /><br />\n";}
}
?>

Link to comment
https://forums.phpfreaks.com/topic/239325-conditional-select-problem/
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.