Jump to content

How would I go about this?


Orionsbelter

Recommended Posts

Okay, so I have a table in my database with a field to input a weight, the row will have an ID field which is the primary key. 

 

The issue is I need to generate a form which I'm doing as a while loop, this form will have a textfield for each record in the table 

 

I then need the user to fill our the form and submit the weights. 

 

How would I then go about creating the code to deal with the text fields as am unsure how many rows will be extracted from the table as they will differ from time to time. 

 

 

Link to comment
Share on other sites

you would use an array name for the form field. see this link - http://php.net/html#faq.html.arrays

 

the array index would be the id -

$id = from your database ...

echo "<input type='text' name='weight[$id]' >";

the submitted array would be in $_POST['weight'], which you could/would loop over using a foreach loop to get the id and the corresponding value.

Link to comment
Share on other sites

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.