- This topic is empty.
-
AuthorPosts
-
May 6, 2014 at 1:05 pm #169347
Josh Johnson
ParticipantSo I have 6 field pairs within a form:
http://i.imgur.com/c6Dgm1d.png
Which in code is just the following repeated 6 times respectively:
<fieldset> <input type="text" name="skill-1" value="" class="field-1-2 float-left" placeholder="Skill"> <div class="select-container field-1-2 float-right"> <select name="skill-rating-1"> <option value="">Skill rating</option> <option value="1">1 (Beginner)</option> <option value="2">2 (Amateur)</option> <option value="3">3 (Intermediate)</option> <option value="4">4 (Pro)</option> <option value="5">5 (Expert)</option> </select> </div> </fieldset>
What I would like to know is how I would go about grabbing that data whilst maintaining field pairs are kept together (i.e skill one goes with skill rating one etc). Once I have that data I can then insert it as a row in the following database structure:
+--------------+-------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +--------------+-------------+------+-----+---------+-------+ | skill_id | int(11) | NO | PRI | NULL | | | skill | varchar(50) | NO | PRI | NULL | | | skill_rating | int(11) | YES | | NULL | | +--------------+-------------+------+-----+---------+-------+
Thanks
May 6, 2014 at 4:30 pm #169364shaneisme
ParticipantYes, each of the pairs would need a unique name you could parse to know they go together.
For instance
skill_1
goes withskill_rating_1
. You could build this dynamically of course just using an increment (eg.$i++
) in your foreach loop when rendering the form to the user.Then you could just parse looking for the
_1
and pair them together.I’m sure there are other ways too, just what I thought up off the top of my head :)
-
AuthorPosts
- The forum ‘Back End’ is closed to new topics and replies.