question regarding select query
Please note, I am a beginner with all of this.
I am trying to select all the group ids of which a user_id attached to.
so the table I am querying has structure of:
group_id | user_id
currently it just grabs one group ID where the user ID is attached.
here is my query:
$ID = $_SESSION['myuserid'];
$get_group = mysql_query("SELECT group_id FROM group_association_tb WHERE user_id = $ID");
$groups = mysql开发者_JAVA百科_fetch_assoc($get_group);
regards,
$get_group
is a MySql result set, so you will need to loop through it to get all the group_id
entries:
$groups = array();
while ($row = mysql_fetch_assoc($get_group)) {
$groups[] = $row["group_id"];
}
now the $groups
array will hold all of your group ids.
精彩评论