I am confused as to display information from my contact table depending on who logged in.
also, should I change my admin table name to users?


Admin Table

`id` int(11) NOT NULL auto_increment primary key
  `username` varchar(40) default NULL,
  `password` varchar(40) default NULL,
  `level` char(1) default NULL,
  `email` varchar(255) default NULL,
  `last_login` datetime default NULL

Contacts Table

`id` int(11) NOT NULL auto_increment primary key
  `first_name` varchar(100) default NULL,
  `last_name` varchar(100) default NULL,
  `address` char(100) default NULL,
  `city` varchar(255) default NULL,
  `state` varchar(255) default NULL,
  `zipcode` varchar(30) default NULL,

If only admin's details are stored in admin table, then you don't need to change anything. But if the table is used for all the users, then for relevancy, you can have your table name as users.
Why not make id of contacts table a foreign key ? So, for every row in contacts table, there exist a record in users table. Doing so, when you need to display the details of a particular user, you just need his id.

ok..
I don't know anything about foreign keys, so i am unsure how to do that, i am searching, now.. Thanks

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.