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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux