4 Replies - 1855 Views - Last Post: 28 January 2013 - 11:45 AM

#1 snig08  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 18
  • Joined: 22-January 13

Sharing information between two tables

Posted 28 January 2013 - 09:29 AM

Ok my website is almost done and there is just a couple more things that need completing. My biggest problem is that I need to implement privileges for certain user groups.
for example I have two tables the first (members) stores information on the members like name, rank and privilege.

on my 2nd table (ranks) I have rank names, and the privilege number associated to it.

on my php website I can test for the privilege if I added a number to the members.privilege just so I Know its working.
I have set up relations so that the rank names will appear in the members table but I need to also set up a relation to add the privilege to the members WHERE the rank name corresponds to the right privilege. At the minute if I add a "1" privilege on the ranks table all the members have "1".
Any ideas?? Thanks

Is This A Good Question/Topic? 0
  • +

Replies To: Sharing information between two tables

#2 modi123_1  Icon User is offline

  • Suitor #2
  • member icon



Reputation: 8964
  • View blog
  • Posts: 33,624
  • Joined: 12-June 08

Re: Sharing information between two tables

Posted 28 January 2013 - 09:37 AM

Quote

I have two tables the first (members) stores information on the members like name, rank and privilege.

Why would you set up a single user to privilege system? It sounds like one user can have many privileges... so make up a table of user ids to privilege ids.

Quote

I have set up relations so that the rank names will appear in the members table but I need to also set up a relation to add the privilege to the members WHERE the rank name corresponds to the right privilege.

What?
Was This Post Helpful? 0
  • +
  • -

#3 snig08  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 18
  • Joined: 22-January 13

Re: Sharing information between two tables

Posted 28 January 2013 - 10:46 AM

It doesn't matter anymore I fixed my problem :)
Was This Post Helpful? 0
  • +
  • -

#4 modi123_1  Icon User is offline

  • Suitor #2
  • member icon



Reputation: 8964
  • View blog
  • Posts: 33,624
  • Joined: 12-June 08

Re: Sharing information between two tables

Posted 28 January 2013 - 10:47 AM

Care to explain?
Was This Post Helpful? 0
  • +
  • -

#5 snig08  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 18
  • Joined: 22-January 13

Re: Sharing information between two tables

Posted 28 January 2013 - 11:45 AM

Well I realised that it was stupid of me to want to use the privileged value from the ranks table in the members table. So on the ranks table I associated a Rank Name to a privilege value. On the members table I have the members a Rank (FK from ranks table). Then I handled the rest within my php code here is the SQL and php code that make it work.
	$sql="SELECT Member_Rank, Privilege FROM members, ranks WHERE Member_Names='$_SESSION[myusername]' AND Member_Rank=Rank_Name";
In the SQL code I used some other values for something else.
$rank = mysql_query($sql); 
$query_row=mysql_fetch_array($rank);
if($query_row[Privilege]==1){


Was This Post Helpful? 0
  • +
  • -

Page 1 of 1