ashish11 Posted August 4, 2013 Share Posted August 4, 2013 (edited) 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><?Phpinclude('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="<?phpecho $result['optionb'];?>" /><?phpecho $result['optionb'];?><br/><input type="radio" name="a" value="<?phpecho $result['optionc'];?>" /><?phpecho $result['optionc'];?><br/><input type="radio" name="a" value="<?phpecho $result['optiond']; ?>" /><?phpecho $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 August 4, 2013 by ashish11 Quote Link to comment https://forums.phpfreaks.com/topic/280811-i-have-done-coding-for-online-exami-want-that-when-click-on-submit-button-than-show-the-resul-of-corrrect-and-wrong-answerplease-help-me-soon/ Share on other sites More sharing options...
ashish11 Posted August 4, 2013 Author Share Posted August 4, 2013 (edited) hi Edited August 4, 2013 by ashish11 Quote Link to comment https://forums.phpfreaks.com/topic/280811-i-have-done-coding-for-online-exami-want-that-when-click-on-submit-button-than-show-the-resul-of-corrrect-and-wrong-answerplease-help-me-soon/#findComment-1443399 Share on other sites More sharing options...
ashish11 Posted August 4, 2013 Author Share Posted August 4, 2013 hello friend please help me in my code soon..i need urgent this code..if you have any query regarding code then post here I will tell you... Quote Link to comment https://forums.phpfreaks.com/topic/280811-i-have-done-coding-for-online-exami-want-that-when-click-on-submit-button-than-show-the-resul-of-corrrect-and-wrong-answerplease-help-me-soon/#findComment-1443422 Share on other sites More sharing options...
KevinM1 Posted August 4, 2013 Share Posted August 4, 2013 (edited) 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 August 4, 2013 by KevinM1 Quote Link to comment https://forums.phpfreaks.com/topic/280811-i-have-done-coding-for-online-exami-want-that-when-click-on-submit-button-than-show-the-resul-of-corrrect-and-wrong-answerplease-help-me-soon/#findComment-1443434 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.