iamdaboss Posted September 2, 2007 Share Posted September 2, 2007 Hi! I have a PHP page which displays a table from MySQL. The table has four columns, the first three cannot be altered whereas the 'Final' column is read/write. So, this PHP page displays all the columns and has a text box for the fourth column('Final') displaying the existing value in a text box which can be changed by user and the same has to be updated in MySql table. Therefore when the user changes the value of 'Final' and hits 'enter' key, the new 'Final' value and corresponding 'Value1' has to be submitted so that the database can be updated. This is not happening because if the database table has 100 columns I am displaying only 30 per page and the 'Value1' from the last row is being submitted. Example: 'Value1' range is 1.....100 Page1: Displays a table with 30 rows with 'Value1' = 1....30 I change 'Final' = 'abc' of a row with 'Value1' = '20' The form should return 'abc' and '20' . But, the current code returns 'Value1' = '30' Any help with this issue would be greatly appreciated. Thank you Code>>> <form id="form1" name="form1" method="post" action=""> <table width="100%" border="1"> <tr> <td>Value1</td> <td>Value2</td> <td>Value3</td> <td>Final</td> </tr> <?php do { ?> <tr> <td height="27"><label> <input type="text" readonly="readonly" size="12" style="border:hidden" name="Value1" id="Value1" value="<?php echo $row_Recordset1['Value1']; ?>" /> </label> </td> <td><?php echo $row_Recordset1['Value2']; ?></td> <td><?php echo $row_Recordset1['Value3']; ?></td> <td><label> <input type="text" name="Finalval" id="Finalval" accept="text/plain" onchange="form.submit()" value="<?php echo $row_Recordset1['Final']; ?>" /> </label></td> </tr> <?php } while ($row_Recordset1 = mysql_fetch_assoc($Recordset1)); ?> </table> </form> ??? Quote Link to comment https://forums.phpfreaks.com/topic/67698-php-forms-and-mysql/ Share on other sites More sharing options...
soycharliente Posted September 2, 2007 Share Posted September 2, 2007 You need to make each input box have a unique name. Quote Link to comment https://forums.phpfreaks.com/topic/67698-php-forms-and-mysql/#findComment-340093 Share on other sites More sharing options...
iamdaboss Posted September 2, 2007 Author Share Posted September 2, 2007 You need to make each input box have a unique name. you mean for both 'Value1' and 'Final' ? If yes, then i think assigning the value of 'Value1' to the input box name would solve the problem....correct me if i am wrong. Quote Link to comment https://forums.phpfreaks.com/topic/67698-php-forms-and-mysql/#findComment-340103 Share on other sites More sharing options...
soycharliente Posted September 4, 2007 Share Posted September 4, 2007 You're creating a ton of table rows with an input box that has the same id every time. Of course it's only going to submit the last one. Quote Link to comment https://forums.phpfreaks.com/topic/67698-php-forms-and-mysql/#findComment-341097 Share on other sites More sharing options...
iamdaboss Posted September 5, 2007 Author Share Posted September 5, 2007 You're creating a ton of table rows with an input box that has the same id every time. Of course it's only going to submit the last one. I tried giving a different name for each input box and it works. When i hit submit the updated values are sent but all the values for the 30 rows are sent though i have changed only one input box. Any solutions for this problem ? Quote Link to comment https://forums.phpfreaks.com/topic/67698-php-forms-and-mysql/#findComment-342132 Share on other sites More sharing options...
soycharliente Posted September 6, 2007 Share Posted September 6, 2007 You could make them default all to not have input boxes, have a link to change the value, then the box comes up to type into. Only one input box that way. Quote Link to comment https://forums.phpfreaks.com/topic/67698-php-forms-and-mysql/#findComment-342754 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.