title: list numer of posts per category
body: <p>Trying to get a code to display the categories of my posts and Im having an issue with presenting the number of posts per category.</p>
  
  <p>well, you get my point while looking in the code, now the total number of categories is listed on every category...</p>
  
  <p>here we go:</p>
  
  <pre><code>&lt;?php 
  $listresult = mysql_query("SELECT distinct category FROM test_blog") 
  or die(mysql_error());
  
  $totalpostspercategory = mysql_num_rows($listresult); 
  
  echo "&lt;ul&gt;";
    while($row = mysql_fetch_array( $listresult )) {
  
  if (strlen($row['category']) &gt; 45) {
      $row['category'] = substr($row['category'],0,45) . " ...";
  } 
  
  echo "&lt;li&gt;&lt;a href='index.php?category=" . $row['id'] . "'&gt;" . $row['category'] ."&lt;/a&gt; (" . $totalpostspercategory . ")&lt;/li&gt;";
  }
  echo "&lt;/ul&gt;";
  
  ?&gt;
  </code></pre>