Note that there are some explanatory texts on larger screens.

plurals
  1. POHow can I get value of a text box which is looped using post method to insert value in database?
    primarykey
    data
    text
    <p>I had following code.My textbox attend is looped for number of times.I want to get value of each attend when my form is post to insert value in database.</p> <pre><code> &lt;form method="post" action="insert.php"&gt; &lt;label&gt;Subject&lt;/label&gt; &lt;input type="text" maxlength="30" name="subject" /&gt; &lt;label&gt;Total Lectures&lt;/label&gt; &lt;input type="text" maxlength="30" name="total" /&gt; &lt;table width="537" border="1"&gt; &lt;tr&gt; &lt;td width="90"&gt;Name&lt;/td&gt; &lt;td width="139"&gt;Roll Number &lt;/td&gt; &lt;td width="136"&gt;&amp;nbsp;&lt;/td&gt; &lt;td width="144"&gt;Attendence&lt;/td&gt; &lt;/tr&gt; &lt;?php $query=mysql_query("SELECT * FROM STUDENT"); $i=0; while($rec=mysql_fetch_array($query)){ $i++; ?&gt; &lt;tr&gt; &lt;td&gt;&lt;?php echo $rec['name']; ?&gt;&lt;/td&gt; &lt;td&gt;&lt;?php echo $rec['roll_number']; ?&gt;&lt;/td&gt; &lt;td&gt;&amp;nbsp;&lt;/td&gt; &lt;td&gt;&lt;input type="text" maxlength="10" name="atten" /&gt;&lt;/td&gt; &lt;/tr&gt; &lt;?php } ?&gt; &lt;/table&gt; &lt;input type="submit" value="submit" /&gt; &lt;/form&gt; </code></pre> <p>and my insert.php page is</p> <pre><code>if($_SERVER['REQUEST_METHOD']=='POST'){ $query=mysql_query("SELECT * FROM STUDENT"); while($rec=mysql_fetch_array($query)){ $attend=$_POST['atten']; $subject=$_POST['subject']; $total=$_POST['total']; $query1=mysql_query("INSERT INTO course VALUES('$i','$subject','$total','$attend','')") or die(mysql_error()); } } </code></pre> <p>I am getting only 1 value of text box.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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