开发者

question regarding select query

开发者 https://www.devze.com 2023-02-20 21:25 出处:网络
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.

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消