ok Posted December 1, 2008 Share Posted December 1, 2008 Hi guys I'm currently working on a "Tell a friend program". I have 2 tables, 1. members 2. invited Ok here is the logic anyone can join the system by referring their friends as many as they can, whoever join the system will be record his name into 'members' table and the friends he invited will be recorded into 'invited' table, of course he can invite as many as he can. Now what i want is to count the total numbers of invited friends that is also sucessfully joined the system (that appear also in members table) and finally assign this total number to the referring member. example; john referred 30 How do you assign this numbers of invited friends into each referrering members. Can you show me class or function for this type of logic. Sorry if my english is not perfect. Thank you in advance. Link to comment https://forums.phpfreaks.com/topic/134956-help-me-with-this-programmin-logic-or-give-example/ Share on other sites More sharing options...
ok Posted December 1, 2008 Author Share Posted December 1, 2008 this is basically what is in my mind right now. <?php function member_ranking($referer_name, $total_num_of_invited, $names_of_invited){ } ?> If you have better function or class than this please show me or teach me. thank you. Link to comment https://forums.phpfreaks.com/topic/134956-help-me-with-this-programmin-logic-or-give-example/#findComment-702839 Share on other sites More sharing options...
ok Posted December 1, 2008 Author Share Posted December 1, 2008 my 2nd question is how does a function/class hold this information for each members that have had referred their friends? Link to comment https://forums.phpfreaks.com/topic/134956-help-me-with-this-programmin-logic-or-give-example/#findComment-702840 Share on other sites More sharing options...
dimond345 Posted December 1, 2008 Share Posted December 1, 2008 Hello. Now I only thinking about this part of portal, but have some ideas about it. Right now I have MySQL DB with table: users - all users that registered in system, CREATE TABLE `users` ( `ID` int(12) NOT NULL auto_increment, `FNAME` varchar(255) collate utf8_unicode_ci NOT NULL, `LNAME` varchar(255) collate utf8_unicode_ci NOT NULL, `EMAIL` varchar(255) collate utf8_unicode_ci NOT NULL, `INTEREST` text collate utf8_unicode_ci NOT NULL, `PASSWORD` varchar(255) collate utf8_unicode_ci NOT NULL, `RATE` varchar(100) collate utf8_unicode_ci NOT NULL, `STATUS` smallint(2) NOT NULL, PRIMARY KEY (`ID`) ) ENGINE=MyISAM AUTO_INCREMENT=8 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=8 ; This user may invite new users, that will be recorded in this table with STATUS=2 (invited); And in new DB TABLE invited(only in my mind right now) CREATE TABLE `invited` ( `USER_ID` int(12) NOT NULL, `INVITED_ID` int(12) NOT NULL ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; will be created new record: INSERT INTO `invited` ( `USER_ID` , `CONTACT_ID` ) VALUES ('1', '7'); After this to new user you may send email with some info about your site and how to register. Then user register on your site, you only change STATUS=1; and this user seen as friend of you 1 user. For this I have another DB Table with records: Contacts: CREATE TABLE `contacts` ( `USER_ID` int(12) NOT NULL, `CONTACT_ID` int(12) NOT NULL ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; After this you may by simple sql query in any time have information about: 1. who was invated by whom. 2. who is friend of this person. $sql_query = "SELECT FNAME,ID,LNAME,STATUS FROM `".DB_PREFIX."_users`, ".DB_PREFIX."_contacts WHERE ".DB_PREFIX."_users.ID = ".DB_PREFIX."_contacts.CONTACT_ID AND ".DB_PREFIX."_contacts.USER_ID = '".$ID."' ORDER BY `RATE` ASC;"; change only DB_PREFIX and title of table and filds and you will recive all info. $my_sql_class->sql_query($sql_query); while ($row = $my_sql_class->sql_fetchassoc()) { switch ($row['STATUS']) { case 1: array_push($this->contact_ofline_list_array, $row);break; case 2: array_push($this->contact_ofline_list_array, $row);break; default: array_push($this->contact_online_list_array, $row);break; } } Some thing like this. Link to comment https://forums.phpfreaks.com/topic/134956-help-me-with-this-programmin-logic-or-give-example/#findComment-702843 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.