What's new
  • Welcome to PHCorner forums. Take a moment to sign up and gain unlimited access and extra privileges that guests are not entitled to, such as: All that and more! Registration is quick, simple and absolutely free. Join our community today!

Gusto ko sana magtanong kaso baka walang sumagot

m0stwanted143

Established
Joined
Feb 8, 2016
Messages
857
Reaction
167
Online examination web based
Php and javascript

Ayaw ma lagay yung question and option pero may countdown timer sya di lang na didisplay
 

m0stwanted143

Established
load_questions.php

<?php
session_start();
include "../config/db_connect.php";
$question_no="";
$question="";
$opt1="";
$opt2="";
$opt3="";
$opt4="";
$answer="";
$count=0;
$ans="";

$queno =$_GET['questionno'];
if(isset($_SESSION["answer"][$queno]))
{
$ans=$_SESSION["answer"][$queno];
}

$res=mysqli_query($conn, "SELECT * from exam_questions
where examname= 'quizko'");
$count = mysqli_num_rows($res);
if($count==0)
{
echo "over";
}
else
{
while($row=mysqli_fetch_array($res))
{
$question_no=$row["$queno"];
$question=$row["question"];
$opt1=$row["opt1"];
$opt2=$row["op2"];
$opt3=$row["opt3"];
$opt4=$row["opt4"];

}
?>
<br>
<table>
<tr>
<td style="font-weight: bold; fon-size: 16px; padding-left: 5px" colspan="2">
<?php echo "".$queno.".) ".$question; ?>
</td>
</tr>
</table>
<table>
<tr>
<td>
<input style="radio" name="r1" id="r1" value="<?php echo $opt1; ?>">
<?php
if ($answer==$opt1)
{
echo "checked";
}
?>
</td>
<td style="padding-left: 10px">
<?php
if (strpos($opt1,'images/')!=false)
{
?>
<img scr="admin/<?php echo $opt1;?>" height="30px" width="30">
<?php
}
else
{
echo $opt2;
}
?>
</td>
</tr>

</table>

<?php
}
?>
 
Comment

m0stwanted143

Established
load_total_que.php

<?php
session_start();
include("../config/db_connect.php");
$total_que = 0;
$res1=mysqli_query($conn, "SELECT * FROM exam_questions WHERE examname = '$_SESSION[examname]'");
$total_que= mysqli_num_rows($res1);
echo $total_que;

?>
 
Comment

m0stwanted143

Established
dashboard.php

<?php
session_start();
include("header.php");
?>
<!-- /header -->

<div class="row" style="...">

<div class="col-lg-6 col-lg-push-3" style="...">

<br>

<br>
<div class="row"class="col-lg-3 col-lg-push-10">

<div id="current_cue" style="float:left">0</div>
<div style="float:left">/</div>
<div id="total_cue" style="float:left">0</div>
</div>

<div class="row" style="margin-top: 30px">
<div class="row">
<div class="col-lg-10 col-lg-push-1" style="min-height: 300px; background-color: white;" id="load_questions">

</div>
</div>
</div>
<div class="row" style="margin-top:10px">
<div class="col-lg-6 col-lg-push-3" style="min-height: 50px">
<div class="col-lg-12 text-center">
<input type="button" class="btn btn-warning" value="Previous" onclick="load_previous();">&nbsp;
<input type="button" class="btn btn-success" value="Next" onclick="load_next();">

</div>
</div>
</div>

</div>
</div>
</div>
<script type="text/javascript">
function load_total_que()
{
var xmlhttp=new XMLHttpRequest();
xmlhttp.onreadystatechange=function() {
if (xmlhttp.readyState == 4 && xmlhttp.status == 200)
{
document.getElementById("total_que").innerHTML=xmlhttp.responseText;
}
};
xmlhttp.open("GET","forajax/load_total_que.php",true);
xmlhttp.send(null);
}
var questionno = "1";
load_questions(questionno);
function load_questions(questionno)
{
document.getElementById("current_que").innerHTML=questionno;
var xmlhttp=new XMLHttpRequest();
xmlhttp.onreadystatechange=function() {
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
if (xmlhttp.responseText=="over")
{
window.location="result.php";
}
else
{
document.getElementById("load_questions").innerHTML = xmlhttp.responseText;
load_total_que();
}
}
};
xmlhttp.open("GET","forajax/load_questions.php?questionno="+ questionno, true);
xmlhttp.send(null);
}
function load_previous()
{
if(questionno=="1")
{
load_questions(questionno);
}
else
{
questionno = eval(questionno)-1;
load_questions(questionno);
}
}
function load_next()
{
questionno=eval(questionno)+1;
load_questions(questionno);
}
</script>

<script src="vendors/jquery/dist/jquery.min.js"></script>
<script src="vendors/popper.js/dist/umd/popper.min.js"></script>
<script src="vendors/jquery-validation/dist/jquery.validate.min.js"></script>
<script src="vendors/jquery-validation-unobtrusive/dist/jquery.validate.unobtrusive.min.js"></script>
<script src="vendors/bootstrap/dist/js/bootstrap.min.js"></script>
<script src="assets/js/main.js"></script>
</body>
</html>
 
Comment

m0stwanted143

Established
Yung problem is di po ma display yung question at option gawa sa java di ata nag pa function pati ung number of question over to wala din di na didisplay..
 
Comment

m0stwanted143

Established
Code:
<?php
session_start();
include("header.php");
?>
<!-- /header -->

<div class="row" style="...">

<div class="col-lg-6 col-lg-push-3" style="...">

<br>

<br>
<div class="row"class="col-lg-3 col-lg-push-10">

<div id="current_cue" style="float:left">0</div>
<div style="float:left">/</div>
<div id="total_cue" style="float:left">0</div>
</div>

<div class="row" style="margin-top: 30px">
<div class="row">
<div class="col-lg-10 col-lg-push-1" style="min-height: 300px; background-color: white;" id="load_questions">

</div>
</div>
</div>
<div class="row" style="margin-top:10px">
<div class="col-lg-6 col-lg-push-3" style="min-height: 50px">
<div class="col-lg-12 text-center">
<input type="button" class="btn btn-warning" value="Previous" onclick="load_previous();">&nbsp;
<input type="button" class="btn btn-success" value="Next" onclick="load_next();">

</div>
</div>
</div>

</div>
</div>
</div>
<script type="text/javascript">
function load_total_que()
{
var xmlhttp=new XMLHttpRequest();
xmlhttp.onreadystatechange=function() {
if (xmlhttp.readyState == 4 && xmlhttp.status == 200)
{
document.getElementById("total_que").innerHTML=xmlhttp.responseText;
}
};
xmlhttp.open("GET","forajax/load_total_que.php",true);
xmlhttp.send(null);
}
var questionno = "1";
load_questions(questionno);
function load_questions(questionno)
{
document.getElementById("current_que").innerHTML=questionno;
var xmlhttp=new XMLHttpRequest();
xmlhttp.onreadystatechange=function() {
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
if (xmlhttp.responseText=="over")
{
window.location="result.php";
}
else
{
document.getElementById("load_questions").innerHTML = xmlhttp.responseText;
load_total_que();
}
}
};
xmlhttp.open("GET","forajax/load_questions.php?questionno="+ questionno, true);
xmlhttp.send(null);
}
function load_previous()
{
if(questionno=="1")
{
load_questions(questionno);
}
else
{
questionno = eval(questionno)-1;
load_questions(questionno);
}
}
function load_next()
{
questionno=eval(questionno)+1;
load_questions(questionno);
}
</script>

<script src="vendors/jquery/dist/jquery.min.js"></script>
<script src="vendors/popper.js/dist/umd/popper.min.js"></script>
<script src="vendors/jquery-validation/dist/jquery.validate.min.js"></script>
<script src="vendors/jquery-validation-unobtrusive/dist/jquery.validate.unobtrusive.min.js"></script>
<script src="vendors/bootstrap/dist/js/bootstrap.min.js"></script>
<script src="assets/js/main.js"></script>
</body>
</html>
 
Comment

m0stwanted143

Established
load_total_que.php
Code:
<?php
session_start();
include("../config/db_connect.php");
$total_que = 0;
$res1=mysqli_query($conn, "SELECT * FROM exam_questions WHERE examname = '$_SESSION[examname]'");
$total_que= mysqli_num_rows($res1);
echo $total_que;

?>
 
Comment

m0stwanted143

Established
load_questions.php
Code:
<?php
session_start();
include "../config/db_connect.php";
$question_no="";
$question="";
$opt1="";
$opt2="";
$opt3="";
$opt4="";
$answer="";
$count=0;
$ans="";

$queno =$_GET['questionno'];
if(isset($_SESSION["answer"][$queno]))
{
$ans=$_SESSION["answer"][$queno];
}

$res=mysqli_query($conn, "SELECT * from exam_questions
where examname= 'quizko'");
$count = mysqli_num_rows($res);
if($count==0)
{
echo "over";
}
else
{
while($row=mysqli_fetch_array($res))
{
$question_no=$row["$queno"];
$question=$row["question"];
$opt1=$row["opt1"];
$opt2=$row["op2"];
$opt3=$row["opt3"];
$opt4=$row["opt4"];

}
?>
<br>
<table>
<tr>
<td style="font-weight: bold; fon-size: 16px; padding-left: 5px" colspan="2">
<?php echo "".$queno.".) ".$question; ?>
</td>
</tr>
</table>
<table>
<tr>
<td>
<input style="radio" name="r1" id="r1" value="<?php echo $opt1; ?>">
<?php
if ($answer==$opt1)
{
echo "checked";
}
?>
</td>
<td style="padding-left: 10px">
<?php
if (strpos($opt1,'images/')!=false)
{
?>
<img scr="admin/<?php echo $opt1;?>" height="30px" width="30">
<?php
}
else
{
echo $opt2;
}
?>
</td>
</tr>

</table>

<?php
}
?>
 
P
PHC_Jayvee
so yung problem ay hindi mo ma echo yung row?

So bakit mo pa pinaste buong code?

Btw use while($data = mysql_fetch_assoc($res))
 

Online statistics

Members online
1,618
Guests online
1,353
Total visitors
2,971

Forum statistics

Threads
1,091,899
Messages
18,324,993
Members
1,525,768
Comments
1,198,372
Attachments
1,427,107
Profile posts
97,971
Top