Jump to content

hello there


thinkthrice

Recommended Posts

Hello everyone,

 

I am pretty new here on this site, I've been working on this for my school project about an online quiz exam...if you check my start.php file,its not sync..i was hoping when i press submit it goes to another question coming from the database but instead its properly ordered already, I know my work is way too complicated and not even near the finished product that i wanted thats why i wanted help here. So if possible i need assistance

 

for some reason i cant upload my database here

post-140762-0-78881600-1361474210_thumb.jpg

add1.php

connection.php

index.php

new.css

post-140762-0-30954000-1361474218_thumb.jpg

start.php

view.php

Link to comment
https://forums.phpfreaks.com/topic/274789-hello-there/
Share on other sites

I think you're missing the point, we're not here to complete your work for you but assist as best we can with specific problems you may encounter. I don't mean to sound brash but I don't want to have to download a project, import a database etc etc and work out what should be done for you. Ask questions and we'll be happy to help.

Link to comment
https://forums.phpfreaks.com/topic/274789-hello-there/#findComment-1413968
Share on other sites

I think you're missing the point, we're not here to complete your work for you but assist as best we can with specific problems you may encounter. I don't mean to sound brash but I don't want to have to download a project, import a database etc etc and work out what should be done for you. Ask questions and we'll be happy to help.

I think you're missing the point, we're not here to complete your work for you but assist as best we can with specific problems you may encounter. I don't mean to sound brash but I don't want to have to download a project, import a database etc etc and work out what should be done for you. Ask questions and we'll be happy to help.

 

ok sir

 

i have this database which contains question i wanted to have a quiz where when i click proceed it goes to another question, as far as I've researched and done ive only managed to make the all the questions display there...the only problem i have now is to make the questions separated from each other

Link to comment
https://forums.phpfreaks.com/topic/274789-hello-there/#findComment-1413970
Share on other sites

well this is the code im using

 

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR...nsitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<title></title>

</head>

 

<body bgcolor="#330099">

<form id="formstart" name="formstart" method="GET" action="start2.php">

<?php

//Include the connection details

include ("connection.php");

 

//Create SQL query

$query="select question,a,b,c,d from dummy";

 

//Execute the query

$qr=mysqli_query($db,$query);

if($qr==false){

echo ("Query cannot be executed!<br>");

echo ("SQL Error : ".mysqli_error($db));

}

//Check the record effected, if no records, display a message

if(mysqli_num_rows($qr)==0){

echo ("No record fetched...<br>");

}//end no record

else{//there is/are record(s)

while ($rekod=mysqli_fetch_array($qr)){//redo to next records

 

 

 

echo $rekod['question'];

echo '<input name="ans" type="radio" value="A" />' . $rekod['a'];

echo '<input name="ans" type="radio" value="A" />' . $rekod['b'];

echo '<input name="ans" type="radio" value="A" />' . $rekod['c'];

echo '<input name="ans" type="radio" value="A" />' . $rekod['d'] . '<br>';

echo '<hr>';

}

}

?>

<input type="submit" name="submit" id="submit" value="SUBMIT"/>

<?php

?>

</form>

</body>

</html>

Link to comment
https://forums.phpfreaks.com/topic/274789-hello-there/#findComment-1413971
Share on other sites

You could try something like this. Store the id of the current question as a session variable. When you query the table get the next question whose id is greater than the stored is. Display question and store the new id.

 

<?php
   session_start();
   if (!isset($_SESSION['qid'])) {
    $_SESSION['qid'] = 0;
   }
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR...nsitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
</head>

<body bgcolor="#330099">
<form id="formstart" name="formstart" method="GET" action="start2.php">
<?php
//Include the connection details
include ("connection.php");

//Create SQL query
$query="SELECT id, question,a,b,c,d
    FROM dummy
    WHERE id > {$_SESSION['qid']}
    ORDER BY id
    LIMIT 1";

//Execute the query
$qr=mysqli_query($db,$query);
if($qr==false){
   echo ("Query cannot be executed!<br>");
   echo ("SQL Error : ".mysqli_error($db));
}
//Check the record effected, if no records, display a message
if(mysqli_num_rows($qr)==0){
   echo ("No record fetched...<br>");
}//end no record
else{//there is/are record(s)
   $rekod=mysqli_fetch_array($qr) ;//redo to next records
    echo $rekod['question'];
    echo '<input name="ans" type="radio" value="A" />' . $rekod['a'];
    echo '<input name="ans" type="radio" value="B" />' . $rekod['b'];
    echo '<input name="ans" type="radio" value="C" />' . $rekod['c'];
    echo '<input name="ans" type="radio" value="D" />' . $rekod['d'] . '<br>';
    echo '<hr>';
   $_SESSION['qid'] = $rekod['id'];
}
?>
<input type="submit" name="submit" id="submit" value="SUBMIT"/>

</form>
</body>
</html>

Link to comment
https://forums.phpfreaks.com/topic/274789-hello-there/#findComment-1413982
Share on other sites

You could try something like this. Store the id of the current question as a session variable. When you query the table get the next question whose id is greater than the stored is. Display question and store the new id.

 

<?php
session_start();
if (!isset($_SESSION['qid'])) {
 $_SESSION['qid'] = 0;
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR...nsitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
</head>

<body bgcolor="#330099">
<form id="formstart" name="formstart" method="GET" action="start2.php">
<?php
//Include the connection details
include ("connection.php");

//Create SQL query
$query="SELECT id, question,a,b,c,d
 FROM dummy
 WHERE id > {$_SESSION['qid']}
 ORDER BY id
 LIMIT 1";

//Execute the query
$qr=mysqli_query($db,$query);
if($qr==false){
echo ("Query cannot be executed!<br>");
echo ("SQL Error : ".mysqli_error($db));
}
//Check the record effected, if no records, display a message
if(mysqli_num_rows($qr)==0){
echo ("No record fetched...<br>");
}//end no record
else{//there is/are record(s)
$rekod=mysqli_fetch_array($qr) ;//redo to next records
 echo $rekod['question'];
 echo '<input name="ans" type="radio" value="A" />' . $rekod['a'];
 echo '<input name="ans" type="radio" value="B" />' . $rekod['b'];
 echo '<input name="ans" type="radio" value="C" />' . $rekod['c'];
 echo '<input name="ans" type="radio" value="D" />' . $rekod['d'] . '<br>';
 echo '<hr>';
$_SESSION['qid'] = $rekod['id'];
}
?>
<input type="submit" name="submit" id="submit" value="SUBMIT"/>

</form>
</body>
</html>

You could try something like this. Store the id of the current question as a session variable. When you query the table get the next question whose id is greater than the stored is. Display question and store the new id.

 

<?php
session_start();
if (!isset($_SESSION['qid'])) {
 $_SESSION['qid'] = 0;
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR...nsitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
</head>

<body bgcolor="#330099">
<form id="formstart" name="formstart" method="GET" action="start2.php">
<?php
//Include the connection details
include ("connection.php");

//Create SQL query
$query="SELECT id, question,a,b,c,d
 FROM dummy
 WHERE id > {$_SESSION['qid']}
 ORDER BY id
 LIMIT 1";

//Execute the query
$qr=mysqli_query($db,$query);
if($qr==false){
echo ("Query cannot be executed!<br>");
echo ("SQL Error : ".mysqli_error($db));
}
//Check the record effected, if no records, display a message
if(mysqli_num_rows($qr)==0){
echo ("No record fetched...<br>");
}//end no record
else{//there is/are record(s)
$rekod=mysqli_fetch_array($qr) ;//redo to next records
 echo $rekod['question'];
 echo '<input name="ans" type="radio" value="A" />' . $rekod['a'];
 echo '<input name="ans" type="radio" value="B" />' . $rekod['b'];
 echo '<input name="ans" type="radio" value="C" />' . $rekod['c'];
 echo '<input name="ans" type="radio" value="D" />' . $rekod['d'] . '<br>';
 echo '<hr>';
$_SESSION['qid'] = $rekod['id'];
}
?>
<input type="submit" name="submit" id="submit" value="SUBMIT"/>

</form>
</body>
</html>

 

thank you for your help sir,.

but it still wont work, this statement is executed after i submit the answer

 

 

if(mysqli_num_rows($qr)==0){

echo ("No record fetched...<br>");

}

Link to comment
https://forums.phpfreaks.com/topic/274789-hello-there/#findComment-1414063
Share on other sites

You could try something like this. Store the id of the current question as a session variable. When you query the table get the next question whose id is greater than the stored is. Display question and store the new id.

 

<?php
session_start();
if (!isset($_SESSION['qid'])) {
 $_SESSION['qid'] = 0;
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR...nsitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
</head>

<body bgcolor="#330099">
<form id="formstart" name="formstart" method="GET" action="start2.php">
<?php
//Include the connection details
include ("connection.php");

//Create SQL query
$query="SELECT id, question,a,b,c,d
 FROM dummy
 WHERE id > {$_SESSION['qid']}
 ORDER BY id
 LIMIT 1";

//Execute the query
$qr=mysqli_query($db,$query);
if($qr==false){
echo ("Query cannot be executed!<br>");
echo ("SQL Error : ".mysqli_error($db));
}
//Check the record effected, if no records, display a message
if(mysqli_num_rows($qr)==0){
echo ("No record fetched...<br>");
}//end no record
else{//there is/are record(s)
$rekod=mysqli_fetch_array($qr) ;//redo to next records
 echo $rekod['question'];
 echo '<input name="ans" type="radio" value="A" />' . $rekod['a'];
 echo '<input name="ans" type="radio" value="B" />' . $rekod['b'];
 echo '<input name="ans" type="radio" value="C" />' . $rekod['c'];
 echo '<input name="ans" type="radio" value="D" />' . $rekod['d'] . '<br>';
 echo '<hr>';
$_SESSION['qid'] = $rekod['id'];
}
?>
<input type="submit" name="submit" id="submit" value="SUBMIT"/>

</form>
</body>
</html>

You could try something like this. Store the id of the current question as a session variable. When you query the table get the next question whose id is greater than the stored is. Display question and store the new id.

 

<?php
session_start();
if (!isset($_SESSION['qid'])) {
 $_SESSION['qid'] = 0;
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR...nsitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
</head>

<body bgcolor="#330099">
<form id="formstart" name="formstart" method="GET" action="start2.php">
<?php
//Include the connection details
include ("connection.php");

//Create SQL query
$query="SELECT id, question,a,b,c,d
 FROM dummy
 WHERE id > {$_SESSION['qid']}
 ORDER BY id
 LIMIT 1";

//Execute the query
$qr=mysqli_query($db,$query);
if($qr==false){
echo ("Query cannot be executed!<br>");
echo ("SQL Error : ".mysqli_error($db));
}
//Check the record effected, if no records, display a message
if(mysqli_num_rows($qr)==0){
echo ("No record fetched...<br>");
}//end no record
else{//there is/are record(s)
$rekod=mysqli_fetch_array($qr) ;//redo to next records
 echo $rekod['question'];
 echo '<input name="ans" type="radio" value="A" />' . $rekod['a'];
 echo '<input name="ans" type="radio" value="B" />' . $rekod['b'];
 echo '<input name="ans" type="radio" value="C" />' . $rekod['c'];
 echo '<input name="ans" type="radio" value="D" />' . $rekod['d'] . '<br>';
 echo '<hr>';
$_SESSION['qid'] = $rekod['id'];
}
?>
<input type="submit" name="submit" id="submit" value="SUBMIT"/>

</form>
</body>
</html>

 

and btw,where did "qid" came from is it constant?

im not really that familiar and im willing to learn

Link to comment
https://forums.phpfreaks.com/topic/274789-hello-there/#findComment-1414064
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.