title: Top users with posts mysql
body: <p>I have 2 tables users | posts.</p>
  
  <p>The <code>posts</code> structure is:</p>
  
  <p>[<code>post_id</code> | <code>post_user_id</code> ]</p>
  
  <p>The <code>users</code> structure is:</p>
  
  <p>[<code>user_id</code> | <code>user_name</code>| <code>user_password</code> ]</p>
  
  <p>Now i want to get the top 5 user with posts </p>
  
  <p>edit 1: </p>
  
  <pre><code>       $cod_sql = "select u.user_name, count(*) as 'TotalNumberofPosts'
  from users u
    join posts p
      on u.user_id=p.post_user_id
  group by user_name
  order by count(*) desc 
  limit 5";
          $top10 = mysql_query($cod_sql1) or die (error_sql(mysql_error(),__LINE__,__FILE__));
  
              echo '&lt;div class="head_panel"&gt;Members&lt;/div&gt; 
                      &lt;div class="body_panel"&gt;
                  &lt;table border="1" width="100%"&gt;
                      &lt;tr&gt;
                      &lt;/tr&gt;   
                      &lt;tr class="tr3"&gt;
                  Top5 : 
                      &lt;/tr&gt;';
  
      if ( $top10 === FALSE ) 
      { 
          // An error has occured 
          print "There was an error running the query" . mysql_error(); 
      } else { 
          while ( $row = mysql_fetch_assoc($top10) ) 
          { 
              print "This is some data from a row&lt;BR /&gt;"; 
              print "Name: ($row) &lt;BR /&gt;"; 
          } 
      }  
  
            }
          break;
  </code></pre>