Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New Coder
    Join Date
    Nov 2012
    Location
    chennai
    Posts
    55
    Thanks
    29
    Thanked 0 Times in 0 Posts

    query executed or not

    Hi,
    Please anyone tell me how to check whether the code is executed or not.

    For example, i'd did the code, while writting the exams in online, my concept is if a student had already attended the question he should not able to write again. So i'd set some images,as not_answered,review_answer,answered. By checking the flag values the images will get changed.
    the following is my code. In that i've to set the not_answered image as default. But i cann't. Please tell me wat i did wrong in that.

    Code:
    $query2="select flag from tablename where id ='$Id' && no ='$no'";	
    		$res=mysql_query($query2);
    		
    		if(!$res)
    		{
    		echo "<a href='newpartshort.php?orderno=$ono&part=$part&qpid=$qpid&board=$board&subject=$subject&StudentId=$StudentId&totalrows=$totalRows1'><img src='img/not_answered.png'></a>";
    		}
    		
    		else 
    		{
    		while($rw = mysql_fetch_array($res)) {
    		$flag1=$rw['flag'];
    		/*if($flag==0)
    		{                     	
    			echo "<a href='newpartshort.php?orderno=$ono&part=$part&qpid=$qpid&board=$board&subject=$subject&StudentId=$StudentId&totalrows=$totalRows1'><img src='img/not_answered.png'></a>";
    		}*/
    		if($flag1==1)
    		{
    			echo "<a href='newpartshort.php?orderno=$ono&part=$part&qpid=$qpid&board=$board&subject=$subject&StudentId=$StudentId&totalrows=$totalRows1'><img src='img/review_answer.png'></a>";
    		}
    		else if($flag1==2)
    		{
    			echo "<a href='newpartshort.php?orderno=$ono&part=$part&qpid=$qpid&board=$board&subject=$subject&StudentId=$StudentId&totalrows=$totalRows1'><img src='img/answered.png'></a>";
    		}
    		else
    		{
    		echo "<a href='newpartshort.php?orderno=$ono&part=$part&qpid=$qpid&board=$board&subject=$subject&StudentId=$StudentId&totalrows=$totalRows1'><img src='img/not_answered.png'></a>";		
    		}
    		}}

  • #2
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,455
    Thanks
    8
    Thanked 1,084 Times in 1,075 Posts
    Check for the number of rows found in the query result ..

    if(mysql_num_rows($res)<1){
    // no results found
    echo "<a href='newpartshort.php?orderno=$ono&part=$part&qpid=$qpid&board=$board&subject=$subject&StudentId=$S tudentId&totalrows=$totalRows1'><img src='img/not_answered.png'></a>";
    }

  • Users who have thanked mlseim for this post:

    gayathri (01-18-2013)

  • #3
    New Coder
    Join Date
    Nov 2012
    Location
    chennai
    Posts
    55
    Thanks
    29
    Thanked 0 Times in 0 Posts
    thanks mlseim. You are right. By checking the number of rows found in the query result , i got the output what i expect.
    Thanks again.

    Please tell me something about the submit and review buttons.

    I've to do another thing. i.e.) I've a submit button and review button. By clicking submit button the answer get saved and the not answered image will change to answered image.

    But by clicking the review button the written answers should get save in a txt file and then the not answered image is get updated to review _answer image.

    How shall i do this. Any ideas please tell me.

  • #4
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,455
    Thanks
    8
    Thanked 1,084 Times in 1,075 Posts
    So you're allowing the student to answer the questions and then go back and review them before they make a "final" answer?

    You have a decision to make on how the concept of answering should work ...

    Either they answer them one at a time and move on, without review, or they answer them all and are able to review them all, and then there is one button that says, "I'm done". Once they click "I'm done", the whole test is finalized.

    You can't have them answer, review, answer, review, etc. You'll never know when the test is finished. There has to be some way to know when they've decided that they are satisfied with their answers.

    You may want an indicator that shows which questions have not yet been answered. Perhaps they can't finalize the test until ALL questions have been answered?

    .... and are the answers multiple choice, or numbers, or text? What kind of test is it?



    .


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •