Orionsbelter Posted December 15, 2013 Share Posted December 15, 2013 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. Quote Link to comment Share on other sites More sharing options...
mac_gyver Posted December 15, 2013 Share Posted December 15, 2013 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. Quote Link to comment Share on other sites More sharing options...
Orionsbelter Posted December 16, 2013 Author Share Posted December 16, 2013 Thanks will look into this now and code something up. Quote Link to comment 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.