I used this code to pull info from the database and into the array.
I then use the session to auto full the form.
When submited I want the next value in the array to be applied to th session.
I use this code but it only works for the first time a form is submited afterwards the value stays the same.
Is is next() the right function?
What would be the bst way to achieve this?
Thanks in advance.
Code:
$stu_quary = "SELECT `uname` FROM `user` WHERE level = 'Normal' AND class = '".$_SESSION['class']."'";
$stu_names=mysql_query($stu_quary);
$stuArr=array();
while($get_stu_info =mysql_fetch_assoc($stu_names))
{
$n = 0;
$stuArr[] = $get_stu_info['uname'];
$_SESSION['selected_s'] = current($stuArr);
}
When submited I want the next value in the array to be applied to th session.
Code:
if(isset($_POST['postComment']))
{
$query = "INSERT INTO ".$_POST['student_name']."_".$_POST['class']." SET name='".$_POST['student_name']."',title='".$_POST['student_name']." Report for Week: ".$_POST['week']."',subject='".$_POST['subject']."',class='".$_POST['class']."',author='".$_POST['author']."',week='".$_POST['week']."',par='".$_POST['par']."',beh='".$_POST['beh']."',lis='".$_POST['lis']."',spe='".$_POST['spe']."',mot='".$_POST['mot']."',ret='".$_POST['ret']."',comments='".$_POST['comment']."',";
$query .="date_posted=NOW(),categoryID='".$_POST['select']."',artchild='0'";
if(!mysql_query($query))
{
echo mysql_error();
}
else
{
$_SESSION['selected_s'] = next($stuArr);
}
Is is next() the right function?
What would be the bst way to achieve this?
Thanks in advance.
Comment