• Hello Fabrik Community

    Fabrik is now in the hands of the development team that brought you Fabrik for Joomla 4. We have recently transitioned the Fabrik site over to a new server and are busy trying to clean it up. We have upgraded the site to Joomla 4 and are running the latest version of Fabrik 4. We have also upgraded the Xenforo forum software to the latest version. Many of the widgets you might have been used to on the forum are no longer operational, many abandoned by the developers. We hope to bring back some of the important ones as we have time.

    Exciting times to be sure.

    The Fabrik 4.0 Official release is now available. In addition, the Fabrik codebase is now available in a public repository. See the notices about these in the announcements section

    We wish to shout out a very big Thank You to all of you who have made donations. They have really helped. But we can always use more...wink..wink..

    Also a big Thank You to those of you who have been assisting others in the forum. This takes a very big burden off of us as we work on bugs, the website and the future of Fabrik.

Need help updating another table with php plugin on form submission

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
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
 
Thank you for replying, I just found the upsert plugin, can't that do the thing I want but without that much coding?
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top