Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Edit - I just realized that your while loop is going to generate something that looks like:</p> <pre><code>&lt;input type="text" name="c_name" size="50" value="A1" /&gt;&lt;br&gt; &lt;input type="text" name="c_name2" size="50" value="B1" /&gt;&lt;br&gt; &lt;input type=button value=\'Submit\' onclick=\'post_value();\'&gt;&lt;br&gt;&lt;br&gt; &lt;input type="text" name="c_name" size="50" value="A2" /&gt;&lt;br&gt; &lt;input type="text" name="c_name2" size="50" value="B2" /&gt;&lt;br&gt; &lt;input type=button value=\'Submit\' onclick=\'post_value();\'&gt;&lt;br&gt;&lt;br&gt; &lt;input type="text" name="c_name" size="50" value="A3" /&gt;&lt;br&gt; &lt;input type="text" name="c_name2" size="50" value="B3" /&gt;&lt;br&gt; &lt;input type=button value=\'Submit\' onclick=\'post_value();\'&gt;&lt;br&gt;&lt;br&gt; </code></pre> <p>This isn't going to work because you have multiple elements named "c_name" and "c_name2" within the same form. I think what you want to do is put your form element inside the while loop like this:</p> <pre><code>&lt;?php $sql="SELECT * from customer"; $rs=mysql_query($sql,$conn) or die(mysql_error()); $ctr = 0; while($result=mysql_fetch_array($rs)) { echo '&lt;form name="frm' . $ctr . '" method="post" action=""&gt; &lt;input type="text" name="c_name" size="50" value="'.$result["sequence"].'" /&gt;&lt;br&gt; &lt;input type="text" name="c_name2" size="50" value="'.$result["company"].'" /&gt;&lt;br&gt; &lt;input type=button value=\'Submit\' onclick=\'post_value(' . $ctr . ');\'&gt;&lt;br&gt;&lt;br&gt;' &lt;/form&gt;'; $ctr++; } ?&gt; </code></pre> <p>Notice how I created a $ctr variable so you can identify each form and how it is passed into post_value. You'll need to use that to grab the correct form like this:</p> <pre><code>&lt;script langauge="javascript"&gt; function post_value(ctr) { opener.document.f1.p_name.value = document.forms["frm" + ctr].c_name.value; opener.document.f1.p_name2.value = document.forms["frm" + ctr].c_name2.value; self.close(); } &lt;/script&gt; </code></pre> <p>By default, mysql_fetch_array returns an array with numeric keys (i.e. 0, 1, 2, etc). If you want to retrieve records by their column name, you need to use:</p> <pre><code>while ($result = mysql_fetch_array($rs, MYSQL_ASSOC)) </code></pre> <p>Look at example 3 here:</p> <p><a href="http://php.net/manual/en/function.mysql-fetch-array.php" rel="nofollow">http://php.net/manual/en/function.mysql-fetch-array.php</a></p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload