title: Wordpress get_var query
body: <p>I have created some custom tables within the WP database, and I'm referencing a table called 'projects' in this instance with this query.</p>
  
  <p>'pr_no' is the Project Number</p>
  
  <pre><code>&lt;?php
  $current_user = wp_get_current_user();
  $projectref = $wpdb-&gt;get_var("SELECT pr_no FROM $wpdb-&gt;projects WHERE ID=$current_user-&gt;ID");
  echo "{$projectref}";
  </code></pre>
  
  <p>However, it echos nothing, and comes up blank. Where have I gone wrong?</p>
  
  <p>At first I thought it was because I'd created my own table within WP, but apparently that's allowed. So I'm stuck!</p>
  
  <p>--Update--</p>
  
  <p>Fixed it for anyone who’s interested, you don’t need the $wdbp prefix on custom tables in a query. Amending the code to below fixes it.</p>
  
  <pre><code>&lt;?php
  $current_user = wp_get_current_user();
  $projectref = $wpdb-&gt;get_var(“SELECT pr_no FROM projects WHERE ID=$current_user-&gt;ID”);
  echo “{$projectref}”;
  </code></pre>