Just create a table to keep track of the groups, something like:
create table groups (
gid int unsigned auto_increment,
gname varchar(40)
);
Then create another table to keep track of which users are in which groups:
create table usergroups (
ugid int unsigned auto_increment,
userid int unsigned not null,
groupid int unsigned not null
);
Then to add a user to a group just:
"INSERT INTO usergroups VALUES ('', '$UserIdFromYourUserTable', '$gidFromGroupsTable');"
And do this for each group the user is in.