0

i wish to capture user input regarding workhistory on one form - how do I catch the same infor structure, ie. company name, position, duration, job description, for 3-4 companies, dynamically in PHP and write it to mySQL. I need direction on how to do this re...form structure and table structure, if its not too much to ask.

2
Contributors
1
Reply
11
Views
4 Years
Discussion Span
Last Post by diafol
0

You could have a js-triggered 'add another company' feature for your form, which would add another 'row' to your form.

<form method="post" action="...">
    <div class="row">
        <label>Company:</label> <input name="company[]">
        <label>Position:</label> <input name="position[]">
        <label>From-To:</label> <input name="from_to[]">
        <label>Description:</label> <textarea name="description[]"></textarea>
    </div>    
    <button id="addrow">Add Company</button>    
    <button type="submit" name="submit">Submit</button>    
</form>

So, that's the type of thing you could do. Capture the "addrow" click event in javascript to add another row (with the same content as in the form already, but with an additional, "delete this company" button for each row. When companies are deleted to just one left, get rid of the delete buttons.

Anyway, that's just an idea.

The MySQL tables, should be pretty straightforward

A general user table (assume PK is user_id)
A user_companies table...

uc_id (PK/autoincrement integer)
user_id (FK)
company [varchar 30?]
position [varchar 30?]
duration [varchar20?]
description [text]

This is not meant as a complete solution, just something to think about with regard to getting started. The form could be hard coded with say 4 rows as opposed to being interactive with js. Up to you.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.