i'm doing online quizz project.
so i'm fetching questioins & answers Randomly from database.
when ever press referesh button/f5 the questions are changing.
wat i require is when the session starts once.the questions could not be change even doing refresh..
thank u all.
eagerly waiting for ur help

Store your selected questions/answers in a session variable, once you've selected them.

<?php
$query="SELECT * FROM test  ORDER BY RAND() limit 5  ";
$result=mysql_query($query)or die("cannot select DB");
$num=mysql_numrows($result);
?>

<form name="myform" id="myform" action='test.php' method='POST' href="javascript: calculate_time()">
<table>
<tr><td style='overfolw-hidden;width:400px;'> Question: </td>
<td style='overfolw-hidden;width:40px;'> OPTION A </td>
<td style='overfolw-hidden;width:40px;'> OPTION B </td>
<td style='overfolw-hidden;width:40px;'> OPTION C </td>
<td style='overfolw-hidden;width:40px;'> OPTION D </td>
</tr>

<?
while($row = mysql_fetch_array($result))
  {

echo"<tr>";
echo "<td> $row[question]</td>";
echo "<td>$row[a]<input type='radio' name='$row[qid]' value='a'> </td>";
echo "<td>$row[b]<input type='radio' name='$row[qid]' value='b'> </td>";
echo "<td>$row[c]<input type='radio' name='$row[qid]' value='c'> </td>";
echo "<td>$row[d]<input type='radio' name='$row[qid]' value='d'> </td>";
echo"</tr>";




}
?>
<tr><td></td><td><input type='submit' value='submit'></tr>
</table> <br/>

</form>

</div>

Quoted Text Here

hi this is the way i'm fetching data from database.can u please guide me ho can i store these varaiables in seesions & how to display .

you can use session like this

<?php
session_start(); 
// make sure to start with this, or else 
// php won't reload the $_SESSION with the previous data

$myTest = 6;
$_SESSION["myTest"] = $myTest;

//Retrieving Data from the previous session
if(isset($_SESSION["myTest"])&&!empty($_SESSION["myTest"])){
    $myTest = $_SESSION["myTest"];
} else { // Storing Information for the next session
    $myTest = 6;
    $_SESSION["myTest"] = $myTest;
}

Let me know if that makes clear.

Man, I just noticed now, I'm confused. is varma51, venter? LOL Anyhow, just let me know if you have additional queries. :D

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.