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
https://forums.phpfreaks.com/topic/284781-how-would-i-go-about-this/
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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.