Jump to content

Recommended Posts

Hello I am trying to setup a form of data filtering to display certain users

 

I have 2 tables "Users" and "Assigned_rolls"

 

What I would like to do is display usernames of all users that have role #1

 

1)So the query would first get all user IDs from the assigned_roles table that have role 1

2)Then pull the names of all the returned use IDs from the users table.

3)Then display the names on a webpage.

 

I am trying to use

 

$result = mysql_query("SELECT ID FROM roles_assigned WHERE role = '1'");
$result1 = mysql_query("SELECT name FROM user WHERE ID = $result ");

 

If I change $result to a single user id that exists in sql, that users name is displayed properly. I don't know how to get the array that is created in the first query to be used as a searchable variable list in the second query so it will return any user id that had a role of 1 assigned to it in the first table.

 

Obviously I am doing something wrong here. Any help is appreciated.

Edited by gummby8
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.