I want to do something on my website, but I still dont know how to do it yet. I have two tables in my database, one is called users and the other is called groups.
fields in the first table
userid - firstname - lastname - email - birthday - gender - password - user_level - signup_date - last_login - activated - account_type - account_owner_name - account_routing_number - account_number - shares.
fields in the second table
groupid - groupname - numberofmembers - paymentamount - paymentrounds - email.
When a user CREATE a group, I insert the group's information in the first table in the same row where his/her information inserted. Also, I send the group's information plus his/her email address to the second table.
I want to know how to do the following:
1) Insert the group's information when someone ENROLL in the group.
2) Select First and Last name of members who are enrolled in the same group.
This is what I tried to do after I made some research.
I created a third table named it users_groups with two fields userid and groupid ... I tried to make a relationship between userid in users_groups and userid in users table and the same relation between groupid fields but it didnt work (When I input any data, the users_groups did not update). Note: I changed the engine to InnoDB and choose CASCADE in both delete and update.
PHP Foreign Key UPDATE SELECT
Moderator: General Moderators
Re: PHP Foreign Key UPDATE SELECT
i would add another field to the second table with an array of the names of members in that specific group. then you can draw out the names using ("select names from second_table where groupid='$group_id'"), this is assuming that you name the new field 'names'.
Re: PHP Foreign Key UPDATE SELECT
But, I will have multiple rows for the same groups with different names.
Re: PHP Foreign Key UPDATE SELECT
im not sure what you're saying but i answered question number 2
Re: PHP Foreign Key UPDATE SELECT
("select names from second_table where groupid='$group_id' and groupname='$group_name'")
Re: PHP Foreign Key UPDATE SELECT
not sure if thats what you are saying