Re: [PHP] need help to update a mysql table from dynamic form
On 2/4/06, Sumeet [EMAIL PROTECTED] wrote: 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 tdstrongEnglish/strong/td tdstrongFran#231;ais/strong/td tdstrongEspa#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'/; Thanx a lot for your answer, but the problem is that for each $key I have 3 column with the same id: categoryen, categoryfr and categoryes. So that gives me three input type=text name=$key with the same $key for the three categories then it goes to the next row. How can I make the difference between the input text that have the same name when updating? see what I mean? Thanx in advance Pat -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] need help to update a mysql table from dynamic form
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 tdstrongEnglish/strong/td tdstrongFran#231;ais/strong/td tdstrongEspa#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 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] need help to update a mysql table from dynamic form
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 tdstrongEnglish/strong/td tdstrongFran#231;ais/strong/td tdstrongEspa#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