title: Displaying Specific Data from mysql database based on user
body: <p>I am trying to have make it so if a user looks at their page they can see the assignments that they have either been working on or have completed.  Then I want to make it so that if they look at another users page they can see the projects that they have created.  </p>
  
  <pre><code>    $my_id = $_SESSION['user_id'];
          $frnd_query = mysql_query("SELECT user_one, user_two FROM frnds WHERE user_one = '$my_id' OR user_two = '$my_id'");
          while($run_frnd = mysql_fetch_array($frnd_query)) {
              $user_one = $run_frnd['user_one'];
              $user_two = $run_frnd['user_two'];
              if($user_one == $my_id) {
                  $user = $user_one;
              } else {
                  $user = $user_two;
              }
              $username = getuser($user, 'username');
              echo "&lt;a href = 'my_ideas.php?user=$user' class = 'list' style=display:block&gt;Ideas&lt;/a&gt;";
  
          ?&gt;  
      &lt;ul&gt;
  
          &lt;li&gt;&lt;a href = '#my_links'&gt;Linked Ideas&lt;/a&gt;&lt;/li&gt;
          &lt;li&gt;&lt;a href = '#idea_chemistry'&gt;My Idea Chemistry&lt;/a&gt;&lt;/li&gt;
          &lt;li&gt;&lt;a href = 'settings.php'&gt;Profile Settings&lt;/a&gt;&lt;/li&gt;&gt;
      &lt;/ul&gt;
  &lt;/div&gt;
  
              &lt;div id = 'my_projects'&gt;
  
      &lt;?php
  
  
              if($user != $_SESSION['user_id']) {
                  $ideas_sql = "SELECT * FROM projects WHERE user_id = $username";
                  $query = mysql_query($ideas_sql) or die(mysql_error());
                  $rsIdeas = mysql_fetch_assoc($query);
  
                  do {
                  ?&gt;
                  &lt;h2&gt;&lt;a href = 'edit_post.php?id=&lt;?php echo $rsIdeas['id']; ?&gt;'&gt;&lt;?php echo $rsIdeas['name']; ?&gt;&lt;/a&gt;&lt;/h2&gt;
  
                      &lt;?php echo $rsIdeas['keywords']; ?&gt;&lt;/p&gt;
                      &lt;p&gt;&lt;?php echo $rsIdeas['description']; ?&gt;&lt;/p&gt;
                      &lt;?php } while ($rsIdeas = mysql_fetch_assoc($query));
  
  
              } else {
  
              $ideas_sql = "SELECT * FROM projects WHERE user_id = $my_id";
              $query = mysql_query($ideas_sql) or die(mysql_error());
              $rsIdeas = mysql_fetch_assoc($query);   
  
  
              do {
              ?&gt;
          &lt;h2&gt;&lt;a href = 'edit_post.php?id=&lt;?php echo $rsIdeas['id']; ?&gt;'&gt;&lt;?php echo $rsIdeas['name']; ?&gt;&lt;/a&gt;&lt;/h2&gt;
  
              &lt;p&gt;&lt;?php echo $rsIdeas['keywords']; ?&gt;&lt;/p&gt;
  
              &lt;p&gt;&lt;?php echo $rsIdeas['description']; ?&gt;&lt;/p&gt; 
              &lt;?php } while ($rsIdeas = mysql_fetch_assoc($query)); 
                  }
                       ?&gt;
                  &lt;?php
                  }
  
              ?&gt;
  </code></pre>
  
  <p>I have googled this and searched for related questions on here but I cannot seem to find anything that helps with my problem.</p>