hi actually iu'm fetching 5 question id from db and saved in an array.
now i'm fetching questions and their respective options from database.
so i'want to save the option in seesions or cookies when ever user selected.
this is my code for fetching questions & ANSWERS.
public function display( )
{
$myqid=array();
$i=0;
$query="SELECT * FROM test ORDER BY RAND() limit 5 ";
$result=mysql_query($query)or die("cannot select DB");
$num=mysql_numrows($result);
while($row = mysql_fetch_array($result))
{
$myid[i]=$row[qid];
i++;
}
$_SEESION['qid']=$myid;
}
if(!isset($_SEESION['qid']))
{
$id=join("," qid);
$query="SELECT * FROM test where qid="$id";
$result=mysql_query($query)or die("cannot select DB");
$num=mysql_numrows($result);
echo "<table>";
echo "<tr>"."<td style='overfolw-hidden;width:400px;'> Question: </td>";
echo "<td style='overfolw-hidden;width:40px;'> OPTION A </td>";
echo "<td style='overfolw-hidden;width:40px;'> OPTION B </td>";
echo "<td style='overfolw-hidden;width:40px;'> OPTION C </td>";
echo "<td style='overfolw-hidden;width:40px;'> OPTION D </td>";
echo "</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='$row[a]'> </td>";
echo "<td>$row[b]<input type='radio' name='$row[qid]' value='$row[b]'> </td>";
echo "<td>$row[c]<input type='radio' name='$row[qid]' value='$row[c]'> </td>";
echo "<td>$row[d]<input type='radio' name='$row[qid]' value='$row[d]'> </td>";
echo"</tr>";
}
echo"</table> <br/>";
it will displaying 5 questions along wtith their answers.now i want to save the selected option in sessions or cookies using php.can u please re-write or correct my code to save the options in sessions using php