Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 01-17-2013, 03:25 AM   PM User | #1
gayathri
New Coder

 
Join Date: Nov 2012
Location: chennai
Posts: 55
Thanks: 29
Thanked 0 Times in 0 Posts
gayathri is an unknown quantity at this point
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>";		
		}
		}}
gayathri is offline   Reply With Quote
Old 01-17-2013, 12:30 PM   PM User | #2
mlseim
Master Coder

 
mlseim's Avatar
 
Join Date: Jun 2003
Location: Cottage Grove, Minnesota
Posts: 9,055
Thanks: 8
Thanked 1,032 Times in 1,023 Posts
mlseim has a spectacular aura aboutmlseim has a spectacular aura aboutmlseim has a spectacular aura about
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>";
}
mlseim is offline   Reply With Quote
Users who have thanked mlseim for this post:
gayathri (01-18-2013)
Old 01-18-2013, 03:48 AM   PM User | #3
gayathri
New Coder

 
Join Date: Nov 2012
Location: chennai
Posts: 55
Thanks: 29
Thanked 0 Times in 0 Posts
gayathri is an unknown quantity at this point
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.
gayathri is offline   Reply With Quote
Old 01-18-2013, 12:29 PM   PM User | #4
mlseim
Master Coder

 
mlseim's Avatar
 
Join Date: Jun 2003
Location: Cottage Grove, Minnesota
Posts: 9,055
Thanks: 8
Thanked 1,032 Times in 1,023 Posts
mlseim has a spectacular aura aboutmlseim has a spectacular aura aboutmlseim has a spectacular aura about
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?



.
mlseim is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 01:32 PM.


Advertisement
Log in to turn off these ads.