Hey guys.
I hope this is in the right forum. I thought perhaps the mysql one, but I'm trying here - perhaps a mod will move it if need be.
Ok... I have a database of users and when a user logs in, I want to be able to display people he has refered to the program for up to four levels...
e.g.
1st 2nd 3rd 4th
me -> bob
-> trevor -> ken
-> phil -> john -> james
(names don't match up to the code below and it doesn't have to appear like this. just an illustration)
I have the following mysql table...
CREATE TABLE `members` (
`member_id` int(4) NOT NULL auto_increment,
`name` varchar(40) NOT NULL,
`username` varchar(40) NOT NULL,
`password` varchar(40) NOT NULL,
`mobile` varchar(20) NOT NULL default '123456',
`email` varchar(50) NOT NULL default 'none@none.com',
`date_joined` date NOT NULL,
`refered_by` int(4) NOT NULL default '2',
`active` char(1) NOT NULL default 'n',
`plan` char(1) NOT NULL default 'b',
PRIMARY KEY (`member_id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
-- ----------------------------
-- Records
-- ----------------------------
INSERT INTO `members` VALUES ('1', 'Admin', 'admin', 'admin', '0', 'admin', '2009-01-20', '0', 'n', 'b');
INSERT INTO `members` VALUES ('2', 'dave', 'dave', 'dave', '0', 'dave', '2009-01-20', '0', 'n', 'b');
INSERT INTO `members` VALUES ('29', 'james', 'james', 'james', '0', 'james', '2009-01-27', '2', 'n', 'b');
INSERT INTO `members` VALUES ('30', 'tom', 'tom', 'tom', '0', 'tom', '2009-02-10', '2', 'n', 'b');
INSERT INTO `members` VALUES ('31', 'phil', 'phil', 'phil', '0', 'phil', '2009-02-10', '2', 'n', 'b');
INSERT INTO `members` VALUES ('32', 'john', 'john', 'john', '0', 'john', '2009-02-11', '30', 'n', 'b');
INSERT INTO `members` VALUES ('33', 'bob', 'bob', 'bob', '0', 'bob', '2009-02-11', '30', 'n', 'b');
INSERT INTO `members` VALUES ('34', 'ken', 'ken', 'ken', '0', 'ken', '2009-02-12', '33', 'n', 'b');
INSERT INTO `members` VALUES ('35', 'steve', 'steve', 'steve', '0', 'steve', '2009-02-12', '34', 'n', 'b');
INSERT INTO `members` VALUES ('36', 'andy', 'andy', 'andy', '0', 'andy', '2009-02-12', '35', 'n', 'b');
Basically, a user logs in and then by their member_id I want to track who they have refered.
I read the entire database into an array, but the iterative part is giving me real problems. Can anyone help with this, or point me to an example they may have done before? Happy to clarify if required.
Many thanks, as ever!
DS



)




Bookmarks