title: How can i make a sql query to run for each record
body: <p>I want to insert some data to DB according to results of a previous running query.</p>
  
  <pre><code>// ------DEFINE ATTACHMENT--------
  $sqlText['attachment']="SELECT
                              issues.`subject`,
                              issue_relations.issue_from_id,
                              issue_relations.issue_to_id,
                              issues.id,
                              attachments.filename,
                              attachments.digest,
                              attachments.id
                          FROM
                              issues
                          INNER JOIN issue_relations ON issues.id = issue_relations.issue_to_id
                          OR issues.id = issue_relations.issue_from_id
                          INNER JOIN attachments ON issue_relations.issue_to_id = attachments.container_id
                          OR issue_relations.issue_from_id = attachments.container_id
                          WHERE
                              issue_from_id = $myPage
                          OR issue_to_id = $myPage
                          GROUP BY
                              digest";
      $sqlQuery_MainMenu = mysql_db_query($db, $sqlText['attachment'], $baglanti) or die("error");
      while($mm_Content=mysql_fetch_array($sqlQuery_MainMenu)){
  // ------MAKE ATTACHMENT--------    
              $myValue=$mm_Content['id'];
          $sqlText['attach']="INSERT INTO attachments (
              container_id,
              container_type,
              filename,
              disk_filename,
              filesize,
              content_type,
              digest,
              downloads,
              author_id,
              created_on,
              description,
              disk_directory
          ) SELECT
              $value,
              container_type,
              filename,
              disk_filename,
              filesize,
              content_type,
              digest,
              downloads,
              author_id,
              created_on,
              description,
              disk_directory
          FROM
              attachments
          WHERE
              attachments.id = $myValue";
      $sqlQuery_MainMenu = mysql_db_query($db, $sqlText['attach'], $baglanti) or die("error");        
  }
  </code></pre>
  
  <p>Now here is the deal <code>$mm_Content['id'];</code>helps me to find how many records needs to be added. 
  And MAKE ATTACHMENT part inserts data to DB. Everything works fine unless if there is only one record to insert.
  But <code>$mm_Content['id'];</code> returns with multiple records most of the time. In that case the code that above gets latest one only. However when i run query inside mysql it shows more records  than one as expected.</p>
  
  <p>To deal with i tried to make an array of <code>$mm_Content['id'];</code> but it did not work (i could not make it run probably). It also brought only one record that is latest. </p>
  
  <p>I want to run MAKE ATTACHMENT PART accordingly the record that returns from <code>$mm_Content['id'];</code></p>
  
  <p>I mean if there are four records then run insert into for times for each <code>$mm_Content['id'];</code> record.</p>
  
  <p>How can i do that.
  Looking forward to hear your precious helps.
  Regards.</p>