title: issue joining two SQL tables
body: <p>I'm having an issue when trying to join two mysql tables together. I have it where its getting the users message, user id correctly that is attached to their account, but it's not getting their username or user profile picture correctly. It's showing the users that is currently logged in profile picture and username. </p>
  
  <p>I'm getting all of the messages that are to the logged in user. Any Idea's on why or what's wrong in my code to be causing this? Thank You In advance. :) </p>
  
  <pre><code>&lt;?
  $stmt = $DB_con-&gt;prepare("SELECT u.userprofile, u.username, m.messageid, m.message FROM users u INNER JOIN messaging m ON u.id=toid WHERE u.id= :toid");
  $stmt-&gt;bindParam(':toid', $_SESSION['user']['id']);
  $stmt-&gt;execute();
  while ($row = $stmt-&gt;fetch(PDO::FETCH_ASSOC))
      {
  
          ?&gt; 
          &lt;div class="col-sm-6"&gt;
              &lt;div class="cblack"&gt;
                  &lt;img src="../images/profile/&lt;?php echo $row['userprofile']; ?&gt;" class="img-rounded" width="150px" height="150px" /&gt;
                  &lt;h4&gt;Message From:
                      &lt;?php echo $row['username'];?&gt;
                  &lt;/h4&gt;
                  &lt;p&gt;Message:
                      &lt;?php echo wordwrap($row['message'],75,"&lt;br&gt;\n",TRUE);  ?&gt; &lt;/p&gt;
                      &lt;a href="viewmessage.php?view_id=&lt;?php echo $row['messageid']; ?&gt;" /&gt;&lt;button type="button" class="btn btn-outline btn-rounded btn-success"&gt;Reply to Message&lt;/button&gt;&lt;/a&gt;
                  &lt;/p&gt;
              &lt;/div&gt;
          &lt;/div&gt;                              
          &lt;?php
      }
  ?&gt;
  </code></pre>