title: show data linked to logged in user and custom database email address
body: <p>I'm new to coding and I need a little help, please</p>
  
  <p>I need logged in user on WordPress(website) linked to my custom DB via email address to show data from my custom DB, like a company, address, etc etc for the logged in user only</p>
  
  <p>I've managed to get the data from the custom DB to display and logged in user info to display too(this part is so i can see logged in info), with the code below</p>
  
  <p>I guess there must be a way of doing this and would I need to have a relationship in DB tying user email and customer email</p>
  
  <p>any help would be much appreciated</p>
  
  <p>thank you for your time</p>
  
  <p>peter</p>
  
  <p>edited</p>
  
  <p>I now get the results from email addresses that are the same in both tables, but I just require the logged in user to be displayed, how can i do that?</p>
  
  <pre><code>      &lt;?php
  
          global $wpdb;
          $result = $wpdb-&gt;get_results( "SELECT * FROM `CustomerT`, `wp_users` where `Email` = `wp_users`.`user_email`");
          foreach ( $result as $print )   { ?&gt;
  
         Customer ID: &lt;?php echo $print-&gt;CustomerID; ?&gt; &lt;/br&gt;
              Company: &lt;?php echo $print-&gt;Company; ?&gt; &lt;/br&gt;
                 Address: &lt;?php echo $print-&gt;Address; ?&gt;&lt;/br&gt;
                        City: &lt;?php echo $print-&gt;City; ?&gt;&lt;/br&gt;
                   County: &lt;?php echo $print-&gt;County; ?&gt;&lt;/br&gt;
                Postcode: &lt;?php echo $print-&gt;Postcode; ?&gt;&lt;/br&gt;
              First Name: &lt;?php echo $print-&gt;FirstName; ?&gt;&lt;/br&gt;
              Last Name: &lt;?php echo $print-&gt;LastName; ?&gt;&lt;/br&gt;
                      Email: &lt;?php echo $print-&gt;Email; ?&gt;&lt;/br&gt;
               Phone No: &lt;?php echo $print-&gt;PhoneNo; ?&gt;&lt;/br&gt;
  &lt;?php global $current_user; wp_get_current_user(); ?&gt;
  
      &lt;?php if ( is_user_logged_in() ) { 
       echo 'Username: ' . $current_user-&gt;user_login . '&lt;br /&gt;';
          echo 'User email: ' . $current_user-&gt;user_email . '&lt;br /&gt;';
          echo 'User first name: ' . $current_user-&gt;user_firstname . '&lt;br /&gt;';
          echo 'User last name: ' . $current_user-&gt;user_lastname . '&lt;br /&gt;';
          echo 'User display name: ' . $current_user-&gt;display_name . '&lt;br /&gt;';
          echo 'User ID: ' . $current_user-&gt;ID . '&lt;br /&gt;';
      } 
      else { wp_loginout(); } ?&gt;
     &lt;?php } ?&gt;
  </code></pre>