How to get a session value from a second table?
<p>I have two tables for the users; a login table and the user profile table.</p>

<p>I want to compare a value from 'userprofiletable' to another value from another table called posts. If the value is equal, it shows a list.</p>

<p>I have the following code. The problem is that it is not comparing the value in the posts table with the value of the session from user profile table.</p>

<p>Could someone help me please?</p>

<pre><code>&lt;?php
$limit = '5';
$dbreq = 'SELECT * FROM `posts` ORDER BY `pos` DESC';
$dbdata = mysql_query($dbreq);
while($dbval = mysql_fetch_array($dbdata))
{
  if (($dbval['city'] == $_SESSION['student_city'])) { //checks for last 4 accomodation
    if ($limit &gt;= '1') {
      echo '&lt;tr&gt;&lt;td&gt;&lt;a href="acomod.php?view='.$dbval['id'].'"&gt;'.$dbval['title'].'&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;';
      $limit = $limit -'1';
    }
  }
}
?&gt;
</code></pre>

<p>I also want to get the value of userprofiletable and post it in the posts table. For example, when somebody make a new post.</p>
