i hav a student_class table containing id,student_id,class,year
i want after every year to add a new row containing id,student_id,class+1 and year+1, and for row having class=4 to stop adding the new row.
i tried something like this but i don get the result i want.
SET GLOBAL event_scheduler = ON;
CREATE EVENT increment_student_form
ON SCHEDULE
STARTS '2013-03-22 11:45:00'
EVERY 1 YEAR
DO
$students=array();
$class=array();
$stud=select * from student_class where class<4;
$row=mysql_fetch_array($stud);
$students[]=$row['student_id'];
$class[]=$row['class'];
for($i=0;$i<sizeof($students);$i++){
INSERT into student class(id,student_id,class,year) values('','$student[i]','$class[i]+1','$year+1')
}
i want after every year to add a new row containing id,student_id,class+1 and year+1, and for row having class=4 to stop adding the new row.
i tried something like this but i don get the result i want.
SET GLOBAL event_scheduler = ON;
CREATE EVENT increment_student_form
ON SCHEDULE
STARTS '2013-03-22 11:45:00'
EVERY 1 YEAR
DO
$students=array();
$class=array();
$stud=select * from student_class where class<4;
$row=mysql_fetch_array($stud);
$students[]=$row['student_id'];
$class[]=$row['class'];
for($i=0;$i<sizeof($students);$i++){
INSERT into student class(id,student_id,class,year) values('','$student[i]','$class[i]+1','$year+1')
}