I need a HTML-based form to tie database records together. The user scenario that I envision is somthing like this:
A super-user does a search of the database and is delivered a table of records based on that search; each record is numbered with the database-record id.
There would also be two text fields next to each record. These text fields would allow:
- the user to make a reference from one record to another. For example, a user could enter into record id #457 the integer 242 to indicate that there is a correlation with record ID #242.
- The user would also describe the type of relationship it is. This could be accomplished with a simple integer in the second field that indicates the type of relationship between the two records.
When the super-user hits the submit button, all of these relationships are saved in a mySqljoin table.
One option is to give me advice on how to implement and code this myself in PHP. However, before I reinvent the wheel, another option is to lead me to a free script that does something similar.
If you’re just looking for a pseudo-code framework, I would do it something like this for the body of the form:
And then when the user submits the form, process it with another loop that goes through each value in the related and type arrays and submits a mysql_query(“INSERT blah blah”). For example:
Of course you should also add an “if in_array” etc. before getting the type to make sure the user entered one and store a default if not, or check the form for completeness before processing it if you want to require them to fill in both fields. You should also run your input through a safety function (escaping quotes etc.) before letting any users input data into your tables.