title: mysql_fetch_assoc returning no values after 1st loop
body: <p>I have created an external function (code below) that calculates an average rating and then echos back that rating to the main page in a dynamic table.  This function sits inside of a do-while loop on the page that is calling it.  I have narrowed the problem down to the msql_fetch_assoc variable <code>"$row_RatingResults"</code>.  It does not return a valid variable after the first iteration through the main pages loop meaning the first value this function returns is calculated correctly but after the first iteration through the loop there is a divide by zero error because <code>$row_RatingResults</code> returns no value.  The $ID variable that is being called comes from the main page(obviously) and is itself coming from a <code>mysql_fetch_assoc (i.e. $ID="rt_".$row_rsResults['outlineID'];)</code>  Code is pasted below...any help here would be much appreciated.  I've starred out some places for safety purposes but know that this does connect to mysql properly.</p>
  
  <pre><code>&lt;?php 
  // contact to database
  require_once('*****');
  mysql_connect("localhost", "*****", "*****") or die ("Error , check your         server connection.");
  mysql_select_db("*****");
  
  require_once("*****");
      function CalculateRating($ID)
  {
  
          $query_RatingResults = "SELECT * FROM rtgitems WHERE (item = '$ID')";
          $RatingResults = mysql_query($query_RatingResults) or die(mysql_error());
          $row_RatingResults = mysql_fetch_assoc($RatingResults);
      $TRate=$row_RatingResults['totalrate'];
      $NoRates=$row_RatingResults['nrrates'];
      $finalrate=$TRate/$NoRates;
      echo $finalrate;            
  }
  ?&gt;
  </code></pre>