title: php mysql- put mysql_fetch_array() result in to a string and split the string by comma
body: <p>I have a mysql table(request) here:</p>
  
  <pre><code>request:
  r_id     item_no
    1         1
    13        10
    22        20
    33        30 
    55        40
  </code></pre>
  
  <p>Now, I'm using php to take r_id out using <code>mysql_fetch_array()</code> and try to put <code>mysql_fetch_array()</code> result in to a string also split the string by comma.</p>
  
  <pre><code>&lt;?php   
  include('config.php'); //connect to mysql
  function f(){
      $sql = "SELECT r_id FROM `request` ";
      $result=mysql_query($sql);
      $string = '';
      $i = 0; 
      while ($row = mysql_fetch_array($result)) {
          $string .= $row[$i];
      }
      $newstring = implode(", ", preg_split("/[\0-9]+/", $string));
      return  $newstring ;
  }
  
  $get=f();
  echo $get;
  ?&gt;
  </code></pre>
  
  <p>But I cannot get the right string form my php code.</p>
  
  <p>I want to get the string like </p>
  
  <pre><code>1,13,22,33,55
  </code></pre>
  
  <p>How can I fix the problem?</p>