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
postsand a table called
categories. 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, say
posts2categorieswhich relates the
poststable entries with their
categoriestable relationships. In other words, if a post had three categories, there will end up being three entries in the
posts2categoriestable. So, and this may seem a bit counter-intuitive, when you create your form you will include only TWO tables,
posts2categories. You will NOT include the
categoriestable. Instead you will use it to popule the selectbox (multiple row) field which you will define for the table
Now, assume your
posts2categoriestable has three fields,
relIDwhich is just an index,
posts_idwhich specifies the relevant
poststable entry and
categories_idwhich specifies the relevant
categoriesentry that are to be connected. When you get to the Tables menu in the phpAddEdit software (Step 3) you will set the Edit Field as
posts_id. Then at Step 4 (Fields) you will select the
categories_idas the only field to include. Next, at Step 5 (Options (1)) you will assign the
categories_idfield to a selectbox (multiple row) or a selectbox (multiple row) other field. Finally, on Step 6 (Options (2)), you will specify the
posts_idfield as the
Relative ID. Then you will use the Populate With… option to fill out the selectbox. Here is where the table
categoriesactually 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.