Jump to content

i have done coding for online exam..i want that when click on submit button than show the resul of corrrect and wrong answer..please help me soon..


ashish11

Recommended Posts

I have manage the database..

database name is online..

table name is question..

column name is serialno,question.optiona,optionb,optionc,optiond,answer..

now I want that when click on answer than should not save in database ..only by comparison to save answer result should be shown...

 

my code is this...

<html>
<head>
<style>
 ul{border:0; margin:0; padding:0;}

#pagination-digg li{
border:0; margin:0; padding:0;
font-size:11px;
list-style:none;
margin-right:2px;
}
#pagination-digg a{
border:solid 1px #9aafe5;
margin-right:2px;
}
#pagination-digg .previous-off,
#pagination-digg .next-off {
border:solid 1px #DEDEDE;
color:#888888;
display:block;
float:left;
font-weight:bold;
margin-right:2px;
padding:3px 4px;
}
#pagination-digg .next a,
#pagination-digg .previous a {
font-weight:bold;
}
#pagination-digg .active{
background:#2e6ab1;
color:#FFFFFF;
font-weight:bold;
display:block;
float:left;
padding:4px 6px;
}
#pagination-digg .non-active{
    background: #ff6633;
color: #ff6633;
font-weight:bold;
display:block;
float:left;
padding:4px 6px;
}
#pagination-digg .non-white{
    background: #FFFFFF;
color: #ff6633;
font-weight:bold;
display:block;
float:left;
padding:4px 6px;
}
#pagination-digg .non-purple{
    background: #800080;
color: #ff6633;
font-weight:bold;
display:block;
float:left;
padding:4px 6px;
}

#pagination-digg a:link,
#pagination-digg a:visited {
color:#0e509e;
display:block;
float:left;
padding:3px 6px;
text-decoration:none;
}
#pagination-digg a:hover{
border:solid 1px #0e509e
}

</style>
</head>
<body>
<?Php
include('connection.php');

error_reporting(0);

$id= $_GET['id'];

        
if(($id)){
$result = mysql_query("SELECT serialno,question,optiona,optionb,optionc,optiond FROM question where serialno=".$id."");
}
else{

$result = mysql_query("SELECT serialno,question,optiona,optionb,optionc,optiond FROM question where serialno=1");
}

while($result=mysql_fetch_array($result))
  {
 
  ?>
 

<form name='question' method="post" >
<?php echo $result['serialno'];?>.<?php echo $result['question'];
?>
<br/>

<input type="radio" name="a" value="<?php echo $result['optiona']; ?>"/><?php echo $result['optiona']; ?>
<br/>
<input type="radio" name="a" value="<?php
echo $result['optionb'];
?>" /><?php
echo $result['optionb'];
?>
<br/>
<input type="radio" name="a" value="<?php
echo $result['optionc'];
?>" /><?php
echo $result['optionc'];
?>
<br/>
<input type="radio" name="a" value="<?php
echo $result['optiond'];

?>" /><?php
echo $result['optiond'];

?>

 <?php  }

?>

<br />

<br /><br>
remind me later
<input type="checkbox" name="rememberMe" value="1" />
<input type="submit" name="next" style="width:50px;" value="Submit"/>
<input type="submit" name="next" style="width:50px;" value="Next"  onClick="window.location.href='online.php?id=<?php if (empty($id)){echo "2"; }else{echo $id+1;}?>';submit_form(); return false;" />
</form>
<?php if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    $status= $_POST['a'];
   
    if(isset($_POST['rememberMe']))
    {
  $status =3;
 }
    elseif(!empty($status)){
        $status =1;
        //echo $status;
    }else{
       
        $status=2;
    }
   
    $query ="SELECT serialno FROM status WHERE serialno = '".$id."'";
$testResult = mysql_query($query) or die('Error, query failed');
   
if(mysql_fetch_array($testResult) == NULL){
  
    $sql = "INSERT INTO status ".
       "(serialno, status) ".
       "VALUES('$id','$status')";
    $result = mysql_query($sql) or die('Error, query failed');
}else{
    //update...
    $sql = "UPDATE status
        SET status='".$status."'
        WHERE serialno='".$id."'";
        $result = mysql_query($sql) or die('Error, query failed');       
}

   

if(! $result )
{
  die('Could not enter data: ' . mysql_error());
}
echo "Entered data successfully\n";

mysql_close($conn);
   $id=$id+1;
header("Location: ?id=$id");
}else {
  echo ""; 
   
};
?>

 

<ul id="pagination-digg">

    <?php $sql = mysql_query("SELECT * FROM status");
    while($res=mysql_fetch_array($sql)){
       
       $no = $res['serialno'];
         $status = $res['status'];
   
   
    ?>
   
<li <?php if($status == 1){ echo "class='active'" ;}else if($status == 2){ echo "class='non-active'";}else if($status == 3){ echo "class='non-purple'";}else { echo "class='non-white'";}?>><a href="?id=<?php echo "$no";?>"><?php echo $no;?></a></li>

    <?php } ?>

</ul>

</body>
</html>

online.php

Edited by ashish11
Link to comment
Share on other sites

1. The next time you post code here, please place it within


tags.  You can do it by simply clicking the <> button on our editor.

 

2. We don't complete other people's projects.  If you're having a specific problem, we'll help you figure out how to solve it, but we're not going to write it for you.  If you need that kind of service, make a post in our Freelancing section.

 

3. We don't really care if you think your problem is urgent.  That's not intended to be rude, it's just reality.  Everyone thinks their problem is urgent.

 

4. Repeatedly bumping your topic is against our ToS.  No one is guaranteed service here.  So, if no one answers your topic, the likely reason is because it's not a clear, concise question.

Edited by KevinM1
Link to comment
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.