emcguire
Member
Guys,
I have a PHP plugin I'm trying to insert a series of records into another table upon submit.
I need to first get all the user ids of all the Joomla users in the "registered" group. There are only 10.
Then I need to insert a new record in another table with each users id and the current rowid of the form they are submitting.
I have this so far, but I know its not right, it's not working.
It is inserting the proper amount of records (10) but the fields I'm inserting are just zeroes, no data.
So I set up a query to grab the user_id's of all users in group "registered" (2)
Then for each of those, I need to insert a new row in another table with the user_id and the current (submitted) form's id.
Any direction here, My syntax is clearly not right.
I have a PHP plugin I'm trying to insert a series of records into another table upon submit.
I need to first get all the user ids of all the Joomla users in the "registered" group. There are only 10.
Then I need to insert a new record in another table with each users id and the current rowid of the form they are submitting.
I have this so far, but I know its not right, it's not working.
It is inserting the proper amount of records (10) but the fields I'm inserting are just zeroes, no data.
PHP:
$myDb = JFactory::getDbo();
$query = $myDb->getQuery(true);
$query->select ('*');
$query->from($myDb->quoteName('nab_user_usergroup_map'));
$query->where($myDb->quoteName('group_id'). " = 2");
$myDb->setQuery($query);
$rows = $myDb->loadObjectList();
$acct_id = $listModel->getRow($rowId);
foreach ($rows as $row)
{
$rep_id = $myDb->quoteName('user_id');
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$query = "INSERT INTO nab_account_approvals (rep_id,related_account) VALUES ('$rep_id','$acct_id')";
$db->setQuery($query);
$db->execute();
}
So I set up a query to grab the user_id's of all users in group "registered" (2)
Then for each of those, I need to insert a new row in another table with the user_id and the current (submitted) form's id.
Any direction here, My syntax is clearly not right.