Start New Discussion within our Web Development Community

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

$query="SELECT * FROM test  ORDER BY RAND() limit 5  ";
$result=mysql_query($query)or die("cannot select DB");

<form name="myform" id="myform" action='test.php' method='POST' href="javascript: calculate_time()">
<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>

while($row = mysql_fetch_array($result))

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>";

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



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

// 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
    $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

This article has been dead for over six months. Start a new discussion instead.