title: Using mysql_fetch_assoc and updating each record
body: <p>Some of my rows have a "," comma as the initial character in the field. So I need to loop through, check if each row has the initial commma, remove it if it does, and update the row.</p>
  
  <p>I am running the following code, which seems to go on an endless loop when the update is called.</p>
  
  <p>When I am just echoing out the result at the end, everything looks fine in the browser. But on execution of the update line below the echo, it seems as if a single datum from the column "Tags" is being populated for every record, instead of just the rows that have the initial commma that I am removing.</p>
  
  <p>Would love help :) </p>
  
  <pre><code>$query = mysql_query("SELECT Tags FROM products")
     or die (mysql_error());
  
  while ($row = mysql_fetch_assoc($query))
  {
      $str = $row['Tags'];
      $initial = substr($str,0,1); 
  
   if ($initial = ",") {
          $str = (ltrim($str, ','));
      }
  
      echo "result: " .$str  . "&lt;br/&gt;";
      $result = "UPDATE products SET Tags = '" .$str ."'";
      mysql_query($result);
  }
  </code></pre>
  
  <p>Thank you.</p>