AlexTCGPro
Member
Hello, I'm new to using fabrik and I'm trying to use it as a way to make my job easier at a college.
I have two tables, one called 'students' and the other 'inscriptions'.
I want that when someone adds an entry in 'students' that another one gets added to 'inscriptions' as well but just with some of the values. Like this:
When you submit a new student you need to put ID, full name, birthday, grade, year, generation, hours and more personal data.
I want that a new row gets created to 'inscriptions' containing only ID, grade and year, the same data that was in the other form.
The idea is that the first list 'students' will only have data from current year, and the list 'inscriptions' will have the story of the students with a list of all the years and hours they had over the years.
I'm working with this code but it's clearly incomplete, I have no experience with mysql and I get lost reading all the documentations
That should update the grade field according to year and id, correct? I haven't tested it yet but that should't work, right? Since no rows exist there's nothing to update, I will really appreciate if you could give me a hand
I have two tables, one called 'students' and the other 'inscriptions'.
I want that when someone adds an entry in 'students' that another one gets added to 'inscriptions' as well but just with some of the values. Like this:
When you submit a new student you need to put ID, full name, birthday, grade, year, generation, hours and more personal data.
I want that a new row gets created to 'inscriptions' containing only ID, grade and year, the same data that was in the other form.
The idea is that the first list 'students' will only have data from current year, and the list 'inscriptions' will have the story of the students with a list of all the years and hours they had over the years.
I'm working with this code but it's clearly incomplete, I have no experience with mysql and I get lost reading all the documentations
Code:
$db = JFactory::getDBO();
$id= JRequest::getVar('students___student_id');
$grade= JRequest::getVar('students___grade');
$year = JRequest::getVar('students___year');
$db->setQuery("update inscriptions set grade = '$grade' where student_id = $id" and year = "$year");
$db->query();
That should update the grade field according to year and id, correct? I haven't tested it yet but that should't work, right? Since no rows exist there's nothing to update, I will really appreciate if you could give me a hand