Re: need help to update a mysql table from dynamic form

From: Date: Sat, 04 Feb 2006 16:12:52 +0000
Subject: Re: need help to update a mysql table from dynamic form
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-229886@lists.php.net to get a copy of this message
Patrick Aljord wrote:
could someone please help me on that one? http://hashphp.org/pastebin?pid=6156 basically this is how I do: I display a mysql table in an html table and I put each value in an input text box. At the bottom I put a submit button to update changes. My question is how do I update everything knowing that I don't know in advance the name of all the input textbox? Here is the code to display the table: <table width=\"1\" border=\"1\"> <tbody>
     <tr>
       <td><strong>English</strong></td>
       <td><strong>Fran&#231;ais</strong></td>
       <td><strong>Espa&#241;ol</strong></td>
     ";
$getdisplaycatname = "select catid,categoryfr,categoryen,categoryes,categoryar from category"; $getdisplaycatnameq = mysql_query($getdisplaycatname); while ($getcatrow = mysql_fetch_array($getdisplaycatnameq)){ //$display_category=mysql_result($getcatnameq, 0); $showcatid=$getcatrow['catid']; $showcat=$getcatrow['categoryfr']; $showcaten=$getcatrow['categoryen']; $showcates=$getcatrow['categoryes']; echo " <tr>
       <td> <input type=\"text\" name=\"<????>\" value=\"$showcaten\"
size=\"18\"/></td>
       <td> <input type=\"text\" name=\"<????>\" value=\"$showcat\"
size=\"18\"/></td>
       <td> <input type=\"text\" name=\"<????>\" value=\"$showcates\"
size=\"18\"/></td>
     </tr>
"; } echo " </tr> </tbody> </table> <br /><input type=\"submit\" name=\"update\" value=\"update\" /></form> "; thanx in advance Pat
not sure of exactly u r try to do...but i can suggest the following code. while ($getcatrow = mysql_fetch_array($getdisplaycatnameq)){ /* assuming getcatrow is an array like getcatrow = array( "field1" => "value1",
                      "field2" => "value2");
*/ while( list($key,$value) = each($getcatrow) ) { echo "<input type='text' name='$key' value='$value'
size='18'/>";
} } u can then complete the code.... -- Sumeet Shroff http://www.prateeksha.com Web Design and Ecommerce Development, Mumbai India

« previous php.general (#229886) next »