Jump to content

Recommended Posts

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

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>";
}

 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.