hoangtaybaokiem1993 Posted January 28, 2019 Share Posted January 28, 2019 Hi All, this is my first post after joining the forum. First of all, I am not a programmer. My field is of Building design and Architecture. I work for an Architectural company. I have a great interest in programming and I started learning php, mysql, html css and jscript, to develop a timesheet application for the company. The web application was created and successully implemented in April this year...! However, all these are purely 'self learning', and it has its own downsides as well. This was just a small intro..., let me come to what i request help on. This is for further development of the application. I have a page to edit the 'utilization' rate of each employee, based on their designations. So the page has all the designations listed as <labels>, next to which a textbox, for the user to fill in the utilization rate. Scenario is that the user will not save each designation's utilization rate immediately after filling it. User will keep going till he fills the last item and then hit the submit button to save. Now, in php I can get all the values from the Request Array. But, how will I know which designations these values belong to? So, what i have as a solution is to name the textboxes with the designation_ids as suffix. May be like; utilTextbox_1, utilTextbox_2, utilTextbox_3 etc... Then when the form is submitted; Check each Request Array element to see if its name starts with 'utilTextbox' If Yes, split it using '_' to get the designation_id Update the db table with the value of the text box Check the next Array Element.....and so on... is this the correct method or is there a better way of doing this? Bảo Kim Quote Link to comment https://forums.phpfreaks.com/topic/308235-bao-kimsaving-data-from-all-text-boxes-in-one-click/ Share on other sites More sharing options...
mac_gyver Posted January 28, 2019 Share Posted January 28, 2019 use an array for the form field name, with the id as the array index - <input type='text' name='utilTextbox[1]'> <input type='text' name='utilTextbox[2]'> ... when the form is submitted, you can loop over the array of data to get the id and the value - foreach($_POST['utilTextbox'] as $id=>$value) { echo "id: $id, value: $value<br>"; } Quote Link to comment https://forums.phpfreaks.com/topic/308235-bao-kimsaving-data-from-all-text-boxes-in-one-click/#findComment-1563981 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.