CodingForums.com

CodingForums.com (http://www.codingforums.com/index.php)
-   PHP (http://www.codingforums.com/forumdisplay.php?f=6)
-   -   query executed or not (http://www.codingforums.com/showthread.php?t=285914)

gayathri 01-17-2013 03:25 AM

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


mlseim 01-17-2013 12:30 PM

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

gayathri 01-18-2013 03:48 AM

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.

mlseim 01-18-2013 12:29 PM

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?



.


All times are GMT +1. The time now is 03:36 PM.

Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.