how to view data row table related to user only? Good day, I need to create a view, which only shows data related to the user logged in user.
When I have a user called "john smith", I create a contents as I like, BUT I don't want other users to see them.

A content can have multiple input from different users, so ONLY admin can see all content.
while, each user, can only see his OWN content which he posted him self.

Think of it like a database system, where each student can add projects for his own records, but each student can see ONLY his own.

I tried looking around first, and I came across this question https://stackoverflow.com/questions/20840490/drupal7-filter-view-based-on-current-users-roles which seemed bit related, but I got lost in the too much explanation because they not entirely related to what I want to achieve.

In user roles permission, I perfectly found (add content, edit own content) but its missing one more thing which I want.."view own content"!!

I think it has something to do with filed permission, or something like when adding a content, set its permission to be view my that user only.

In coding the view to show ONLY table rows related to the that user, maybe something like this: 

global $user;
if (in_array (student_field_name  == $user))
//view the row related to that user;

if (in_array('administrator', $user-&gt;uid))
//show ALL data rows available


To summarize, I want the user to be able to SEE his own data only.
while admin will be able to see ALL content view of that page.
To create a view that is limited to content created by the current user (logged in) and Admin:


create the view as you normally would
Under Advanced, Relationship, create a relationship to Content:Author
Create a Filter, User:Current, Logged in Yes, using the author relationship
Create a filter, Author ID = admin
Create a Filter Group (click on arrow next to Add on Filter Criteria)
'Create a new filter group' and make it look something like this:




This will limit the view to content only created by the currently logged in user and/or Admin, but does not limit access to the nodes themselves, for that you will need a module such as Node Access:


  Nodeaccess is a Drupal access control module which provides view, edit
  and delete access to nodes. Users with the 'grant node permissions'
  permission will have a grant tab on node pages which allows them to
  grant access to that node by user or role. Administrators can set
  default access controls per content type, and also define which roles
  are available to grant permissions to on the node grants tab.