If $a$ is a quadratic residue of odd prime $p$, then is it the case that $a^{-1}$ is also a quadratic residue ?



I notice quadratic residues of odd prime $13$ : 
$$1^2\equiv 12^2\equiv 1\\2^2\equiv 11^2\equiv 4\\3^2\equiv 10^2\equiv 9\\4^2\equiv 9^2\equiv 3\\5^2\equiv 8^2\equiv 12\\6^2\equiv 7^2\equiv 10$$

$4^{-1}=10\\9^{-1}=3\\1^{-1}=1\\12^{-1}=12$ 

Is this true always ? How to go about proving ? thanks! 


Question: CodeIgniter Conditional - Multiple Tables
Answer: You can do with two method.

Method 1. Create function is_team_member($user_email, $team_id) in your model. If user exist, true will be return else false. Pass the returned value to view via controller. Based on the value you can hide the button with use of if condition.

Method 2. You can check the user email in view foreach loop. If $email == $member["email"], set flag to hide button. But in this case, your button should be under the member list. Bur, as we discussed in comment, your member list is above list. So create a variable to store the foreach html content as string. you can run the foreach loop above the button and cho the content after the button. Now based on the flag, you can hide the button.

Ex for method - 1:

In Controller, Team member listing function.

public function index($team_id){

    // Set Var
    $email = $this-&gt;session-&gt;userdata('email');


    $data["team"] = $this-&gt;project_model-&gt;get_team_members($team_id);
    $data["is_joined_user"] = $this-&gt;project_model-&gt;is_team_members($team_id,$email);
    //load view
    $this-&gt;view-&gt;load("view_name", $data);
}


In model:

public function is_team_members($team_id,$email)
{
   $this-&gt;db-&gt;select('*');
   $this-&gt;db-&gt;from('team');
   $this-&gt;db-&gt;join('users', 'users.id = team.user_id');
   $this-&gt;db-&gt;where("user.email",$email);
   $res = $this-&gt;db-&gt;get();
   if($res-&gt;num_rows()&gt;0)
      return true;
   else
     return false;   
}


In view:

&lt;?php
if(! $is_joined_user)
{
?&gt;

&lt;a href="&lt;?php echo $link; ?&gt;" class="button primary radius extrawide"&gt;&lt;h5&gt;Join this Team&lt;/h5&gt;&lt;/a&gt;
&lt;?php
}
?&gt;