Get user info with name or UserID from Mysql/PHP
<p>Can I know what's mistake in here?
I have two tables in my database.
it is this</p>

<p><img src="https://i.stack.imgur.com/BWKyn.png" alt="table"></p>

<p><img src="https://i.stack.imgur.com/sQiNj.png" alt="table2"></p>

<p>I have written the code as search player thing. I'll put the name or userid in the form and it'll process the information of user.</p>

<p>Here is my code </p>

<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;html lang="en"&gt;
 &lt;head&gt;
 &lt;meta charset="utf-8" /&gt;
   &lt;title&gt;&lt;/title&gt;
 &lt;/head&gt;
 &lt;body&gt;
 &lt;form action="" method="post"&gt;
 Search: &lt;input type="text" name="term" /&gt;
 &lt;input type="submit" value="Submit" /&gt;
 &lt;/form&gt;
 &lt;?php
 include('config.php');
 if (!empty($_REQUEST['term']))
 {
 $term = mysql_real_escape_string($_REQUEST['term']);
 $sql = " select u.* from users u inner join ranks r ON (u.UserID = r.UserID) where u.UserID = '%" . $term . "%'";
 $r_query = mysql_query($sql);
 while ($row = mysql_fetch_array($r_query))
  {
  echo 'Name: ' . $row['Name'];
  echo '&lt;br /&gt; Cash: ' . $row['Cash'];
  echo '&lt;br /&gt; Score: ' . $row['Score'];
  echo '&lt;br /&gt; Race: ' . $row['Race'];
  echo '&lt;br /&gt; Horseshoe: ' . $row['Horseshoe'];
  }
 }
?&gt;
&lt;/body&gt;
&lt;/html&gt;</code></pre>
</div>
</div>
</p>