php - creating a web app which allows a member registers other members -
am in tight end, contracted create php web application allows 1 register , user can register 5 more others, other users registered can register 5 members each.
i expected create database save users particular member registered in array, whereby list them out in table form,
the confusing part
- how factor out database structure can save 5 users, when queried list them out (am confused save them in array or separate table). i'd prefer saving in array
- any other user gets registered of 5 registered, linked main referee , of them counted , whole process stops user registers 5 members , 5 members register 5 users each his/her account make 25 total each account
it illustrated as
1. parent - 5 children - then 5 children bears 5 children each, parent acknowledge both children , grandchildren, once children , grandchildren gets 25 in number, reproductive cycle ends parent, children can carry on make theirs 25 also
i have made database needed guidelines build have 3 days complete part.
public function usertable() { $qry = "create table if not exists users( user_id int(8) not null auto_increment, username varchar(35) not null, password varchar(35) not null, referralids varchar(500) not null, totalrefers varchar(35) not null , useridhash varchar(30) not null, date date, time varchar(20) not null, primary key (user_id) )type=innodb"; $result = $this->qry($qry); return; } public function referraltable() { $qry = "create table if not exists refers( user_id int(50) not null, usersregistered varchar(500) not null, referby int(50) not null )type=innodb"; $result = $this->qry($qry); return; } i prefer work 1 table save children in array delimited "," , can start off there confused how save it, , retrieve children's id 1 after other can use query grandchildren
hope not confusing one?? in advance
why need use array? it's simple 1 many relation... create table holds relation, or heck - field in user table...
here example 2 table example...
user table
id | email | name | whatever 1 a@b.c jon 2 j@b.c mel user_registered
register_id | registree_id 1 null 2 1 an example 1 table
id | email | name | whatever | ref_user_id 1 a@b.c jon null 2 j@b.c mel 1 3 f@b.c al 1 than can users 1 registered:
select * user ref_user_id = 1 or amount of people 1 registered
select count(*) user ref_user_id = 1 in both cases, user id of 1, registered first (not refered), , registered user #2
Comments
Post a Comment