Again - let us know if it's working or if you're still having problems. Feedback either way is appreciated.
Once I hear from you I'll commit some additional changes I've made to improve the admin side.
$xoopsMailer->assign('RESULT', 'Newsletter 1<br>Newsletter 2<br>Newsletter 3);
$xoopsMailer->assign('RESULT', 'Newsletter 1' . chr(10) . 'Newsletter 2' . chr(10) . 'Newsletter 3');
implode(',', 'deptIdArray')
implode(',', $deptIdArray)
// first get a list of department IDs
$result = $GLOBALS['xoopsDB']->query('SELECT DISTINCT(DEPTID) FROM ' . $GLOBALS['xoopsDB']->prefix('mydepartments'));
list($deptIdArray) = $GLOBALS['xoopsDB']->fetchRow($result);
// connect to the Access dB
$conn = odbc_connect('mydata','','');
if (!$conn) {
exit("Connection Failed: " . $conn);
}
// now get the Access dB departments not in XOOPS
$accessQuery = "SELECT DEPTID, DEPTNAME FROM DEPARTMENTS WHERE DEPTID NOT IN (" . implode(',', 'deptIdArray') . ")";
$rs = odbc_exec($conn, $accessQuery);
if (!$rs) {
exit("Error in SQL");
}
// now put new departments into 'mydepartments' table
while(odbc_fetch_row($rs)){
list($deptId, $deptName) = odbc_result($rs, 'DEPTID', 'DEPTNAME');
$result = $GLOBALS['xoopsDB']->query("INSERT INTO " . $xoopsDB->prefix('mydepartments') . "($deptId, $deptName));
if (!$result) {
exit('Error inserting new department');
}
++$i;
}
}
exit("{$i} new departments entered into the database");