Note that there are some explanatory texts on larger screens.

plurals
  1. POupdate multiple records in mysql database from php
    primarykey
    data
    text
    <p>In the php code below, if you type something into the top input box and click the button the mysql database is updated. I would like to do the same thing with the form below that has multiple boxes (the actual form will have more than two).</p> <pre><code>&lt;?php ?&gt; &lt;html&gt; &lt;head&gt; &lt;script language='javascript'&gt; function showList(){ var i=0; var rankNum; rankNum = 1; var vfundsym; while (i&lt;=5) { alert(rankNum + " " + document.getElementById("o" + (i+1)).value); i++; rankNum++; } } &lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;form action="getuser3.php" method="post"&gt; &lt;input type="text" id='fundAge' name="fundAge" size="7" maxlength="7" /&gt; &lt;input style="visibility: visible" id="addFundtoDB" type="submit" value="Update Database" /&gt; &lt;/form&gt; &lt;p&gt;The form above updates one record in the database. How can I loop through the form below and update each record?&lt;/p&gt; &lt;form name="orderedlist" action="getuser3.php" method="post"&gt; &lt;form&gt; &lt;table&gt; &lt;tr&gt;&lt;td&gt;&lt;textarea class="orderedlist" name="p1" id="o1"&gt;&lt;/textarea&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt;&lt;td&gt;&lt;textarea class="orderedlist" name="p2" id="o2"&gt;&lt;/textarea&gt;&lt;/td&gt;&lt;/tr&gt; &lt;/table&gt; &lt;input type="button" value="run SHOWLIST function" onclick="showList()"&gt; &lt;/form&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>The getuser3.php code is below.</p> <pre><code>&lt;?php $con = mysql_connect("localhost","username","password"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("devtechw_ajax_demo", $con); mysql_query("UPDATE user SET Age=('$_POST[fundAge]') WHERE ID='2'"); mysql_close($con); ?&gt; </code></pre>
    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