To use this script, just follow each step in order and things should be more or less obvious. Where appropriate, I have added popup notes on headings to offer more detailed information or instructions. However, a couple of powerful features need some more detailed explanation – especially the selectbox_multiple and the selectbox_multiple row options.
- selectbox (other) – a regular select box but with a textbox beside it to add an option if it doesn’t exist. If the select box is populated with values from a database table, the added option value will automatically be added to that table. Since a basic selectbox only allows one selection, the textbox value will replace anything that may be otherwise selected
- selectbox (multiple) vs. selectbox (multiple row) – these are essentially the same field types, the difference being that when the form is processed a selectbox (multiple) will produce a single string value that consists of all the selected items separated by a comma whereas a selectbox (multiple row) will actually add a new database entry for each selected item. Note that the ‘other’ versions of these fields act like the selectbox (other) field described above.
selectbox (multiple row) – In some cases you may want to manipulate multiple tables at once with one of those tables having possibly multiple entries. For example, say you have a table called
posts
and a table calledcategories
. It could be that each post may have multiple categories (e.g., leadership, management, marketing…). In that case you will likely have a connecting table, sayposts2categories
which relates theposts
table entries with theircategories
table relationships. In other words, if a post had three categories, there will end up being three entries in theposts2categories
table. So, and this may seem a bit counter-intuitive, when you create your form you will include only TWO tables,posts
, andposts2categories
. You will NOT include thecategories
table. Instead you will use it to popule the selectbox (multiple row) field which you will define for the tableposts2categories
.Now, assume your
posts2categories
table has three fields,relID
which is just an index,posts_id
which specifies the relevantposts
table entry andcategories_id
which specifies the relevantcategories
entry that are to be connected. When you get to the Tables menu in the phpAddEdit software (Step 3) you will set the Edit Field asposts_id
. Then at Step 4 (Fields) you will select thecategories_id
as the only field to include. Next, at Step 5 (Options (1)) you will assign thecategories_id
field to a selectbox (multiple row) or a selectbox (multiple row) other field. Finally, on Step 6 (Options (2)), you will specify theposts_id
field as theRelative ID
. Then you will use the Populate With… option to fill out the selectbox. Here is where the tablecategories
actually comes into play. For example, you might fill that option with an SQL statement like “SELECT * FROM categories ORDER BY category”.At first, I am sure this process seems a bit strange, but if you think about it for a while, I hope it will make sense to you. Also note that if you choose the selectbox (multiple row) other option, the script is smart enough to use your SQL statement to figure out which table (
categories
) needs to have the “other” option added to.Final Note: if you use this option successfully and can do a better job of explaining it, please send me your explanation.