title: insert column datas of one table in mysql database into another table using php
body: <p>I have two tables(measurementurl and webmeasurements) in a single database(probe_config)
  The first table measurementurl has the following fields</p>
  
  <ol>
  <li>id</li>
  <li>url</li>
  <li>comment</li>
  </ol>
  
  <p>The second table webmeasurements has the following fields</p>
  
  <ol>
  <li>timeout</li>
  <li>url</li>
  <li>wm(id of the particular table,set to autoincrement)</li>
  <li>url_id</li>
  </ol>
  
  <p>I have a php page(wm.php) for inserting  webmeasurements datas to the database in the second table(webmeasurements).i have given the database connections and my job is to bring the id values of the first table(measurementurl) to the second table (webmeasurements) on clicking the submit button of the wm.php page.I have attached the coding.can anyone spot out the mistake.</p>
  
  <p>details of wm.php:</p>
  
  <p>timeout(text box) </p>
  
  <p>url(two radio buttons) and a submit button.<br>
  Following is the coding of wm.php:</p>
  
  <pre><code>&lt;?php
  include_once("connection.php");
  $sql="select * from measurementurl";
  // _Execute query_
  $result=mysql_query($sql,$conn);
  ?&gt;
  
  &lt;form method="post" action="base.php"&gt;
  Timeout :
  &lt;input type="text" name="timeout" /&gt;
  &lt;?php
  while  ($row = mysql_fetch_array($result))
    {
    ?&gt;
    &lt;input type="radio" name="urls" value="&lt;?php echo $row['id']?&gt;"  /&gt;&lt;?php echo $row['url']?&gt;
  
  &lt;?php  
    }
  
  ?&gt;
  &lt;input type="submit" value="submit" name="submit"  /&gt;
  &lt;/form&gt;
  
  &lt;?php
  if(isset($_POST)){
  echo  " &lt; pre&gt;";  
    print_r($_POST);
  } 
  ?&gt;
  </code></pre>
  
  <p>following is base.php of the action part:</p>
  
  <p><code>&lt;?php</code>
  //Begin of Checking Loop<br>
  <code>$idarray = array();</code><br>
  <code>$db = mysql_connect("localhost:3306", "root","mysql") or die("Could not connect.");</code><br>
  <code>if(!$db)</code><br>
  <code>die("no db");</code><br>
  <code>if(!mysql_select_db("probe_config",$db))</code><br>
  <code>die("No database selected.");</code><br>
  <code>$acc1="SELECT id from measurementurl";</code><br>
  <code>$acc2=mysql_query($acc1) or die("Could not select accounts.");</code><br>
  <code>while($acc3=mysql_fetch_assoc($acc2))</code>
        <code>$idarray[] = $acc3[id];</code>  </p>
  
  <p><code>echo "&lt;table border=1&gt;\n";</code><br>
  <code>echo "  &lt;tr&gt;\n";</code><br>
  <code>echo "      &lt;td&gt;\n";</code><br>
  <code>echo "&lt;b&gt;id&lt;/b&gt;";</code><br>
  <code>echo "      &lt;/td&gt;\n";</code><br>
  <code>echo "      &lt;td&gt;\n";</code><br>
  <code>echo "&lt;b&gt;&lt;/b&gt;";</code><br>
  <code>echo "      &lt;/td&gt;\n";</code><br>
  <code>echo "  &lt;/tr&gt;\n";</code>  </p>
  
  <p>// Display the URLS being processed.
  <code>foreach($idarray as $K =&gt; $id)</code><br>
  <code>{</code><br>
      <code>echo "&lt;tr&gt;\n";</code><br>
      <code>echo "&lt;td&gt;\n";</code><br>
      <code>echo $id;</code><br>
      <code>echo "&lt;/td&gt;\n";</code><br>
      <code>ob_flush();</code><br>
      <code>flush();</code><br>
  <code>}</code><br>
  <code>echo "&lt;/table&gt;\n";</code>  </p>
  
  <p><code>$timeout=$_POST['timeout'];</code><br>
  <code>$url=$_POST['url'];</code><br>
  <code>$name=$_POST['name'];</code><br>
  <code>$url_id=$_POST['acc3[$id]'];</code><br>
  <code>echo "$timeout";</code><br>
  <code>echo "&lt;br /&gt;$name";</code><br>
  <code>$sql= "INSERT INTO webmeasurements (url_id, name, timeout) values</code>   <code>($url_id,'$name',$timeout)";</code><br>
  <code>if (!mysql_query($sql,$db))</code><br>
                  <code>{</code>
                      <code>die('Error: ' . mysql_error());</code><br>
                  <code>}</code><br>
                  <code>else</code>
                  <code>{</code>
                      <code>echo "adding Done";</code><br>
                  <code>}</code>  </p>
  
  <p><code>mysql_close('$db');</code>  </p>
  
  <p><code>?&gt;</code>  </p>