your users query only returns the id, lastname and groupid
$query_users = "SELECT id,lastname,groupid FROM da_user ORDER BY lastname asc";
PHP is a cse sensitive language. in the code for the dynamic array, it is using the "groupId" column.
$newmainid = $row_users["groupId"];
it should be a lower case i "groupid"
also, it is using the "ID" column instead of "id":
echo "WAJA[".$n."][".$m."][0] = "."'".WA_DD_Replace($row_users["ID"])."'".";\n";
and the "Name" that is not returned by the recordset:
echo "WAJA[".$n."][".$m."][1] = "."'".WA_DD_Replace($row_users["Name"])."'".";\n";