Search the Community
Showing results for tags 'php code for online examinati'.
-
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