Title: Data base calculation/ query
Last modified: August 31, 2016

---

# Data base calculation/ query

 *  Resolved [epenian](https://wordpress.org/support/users/epenian/)
 * (@epenian)
 * [10 years ago](https://wordpress.org/support/topic/data-base-calculation-query/)
 * I have 12 columns of information and 200 records , basically the first column
   is a suburb and the rest is number of passengers EG
 * Suburb | 1 passenger | 2 passengers | 3 passengers | [up to 11 passengers]
    sydney
   | 55 | 65 | 86 | …200
 * I need a dropdown to select the suburb (which works) then select the number of
   passengers in the second dropdown box. is there a querry / calculation I can 
   do to make this happen or a better way of doing it without a database ?
 * Please help thanks.
 * [https://wordpress.org/plugins/calculated-fields-form/](https://wordpress.org/plugins/calculated-fields-form/)

Viewing 4 replies - 1 through 4 (of 4 total)

 *  Plugin Author [codepeople](https://wordpress.org/support/users/codepeople/)
 * (@codepeople)
 * [10 years ago](https://wordpress.org/support/topic/data-base-calculation-query/#post-7450793)
 * Hi,
 * I’m sorry, but I don’t understand the structure of your records. What are the
   values per passenger, or how are used these values in the final equation?
 * Based on your explanation you need a drop down field with the list of suburb,
   and another drop down field with numbers from 1 to 12.
 * By the way what version of the plugin are you using?
 * Best regards.
 *  Thread Starter [epenian](https://wordpress.org/support/users/epenian/)
 * (@epenian)
 * [10 years ago](https://wordpress.org/support/topic/data-base-calculation-query/#post-7450907)
 * Sorry if I didn’t express correctly … what i am trying to do is based on suburb
   i would like to choose the number of passengers I am collecting so the for should
   be EG
 * Choose a suburb ( which selects a set of records )
    Then choose the number of
   passengers ( which will select one record) which will display the cost.
 * Suburb | P1 | p2 | p3 | p4 | p5| etc
    Sydney | $55 | $60 | $80 | $100 | Liverpool
   | 45 | 50 | 60 | 80 | Parramatta | 70 | 80 | 90 | 110 |
 * Because each suburb has different pricing for passengers. I need the customer
   to select the suburb then choose how many passengers to show them the cost.
 * Hope that helps.
 *  Plugin Author [codepeople](https://wordpress.org/support/users/codepeople/)
 * (@codepeople)
 * [10 years ago](https://wordpress.org/support/topic/data-base-calculation-query/#post-7450931)
 * Hi,
 * In this case you can define a javascript object as database, and use the values
   of the dropdown fields as selectors, for example:
 * 1. Insert a dropdown field for suburbs, I will call it fieldname1, with the choices(
   texts and values):
 * Sydney
    Liverpool Parramatta
 * 2. Insert a second dropdown field for persons, I will call it fieldname2, with
   the choices (texts and values):
 * 1
    2 3 4
 * 3. To use the object with the data from different equations in the form I’ll 
   use an separated field. Insert a “HTML Content” field with the piece of code 
   below to generate the literal object:
 *     ```
       <script>
       database = {
       'Sydney':[55,60,80,100],
       'Liverpool':[45,50,60,80],
       'Parramatta':[70,80,90,100]
       };
       </script>
       ```
   
 * 4. Finally, insert a calculated field whose equation would be as simple as:
 * `database[fieldname1][fieldname2*1-1]`
 * and that’s all.
 * Tip: Javascript is a case sensitive language, pay attention to the suburbs names
   in both places: the dropdown field and the object.
 * Best regards.
 *  Thread Starter [epenian](https://wordpress.org/support/users/epenian/)
 * (@epenian)
 * [10 years ago](https://wordpress.org/support/topic/data-base-calculation-query/#post-7451006)
 * Thank you that worked , so I wont use MySQL database and use the script instead
   all good. Cheers.

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Data base calculation/ query’ is closed to new replies.

 * ![](https://ps.w.org/calculated-fields-form/assets/icon-256x256.jpg?rev=1734377)
 * [Calculated Fields Form](https://wordpress.org/plugins/calculated-fields-form/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/calculated-fields-form/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/calculated-fields-form/)
 * [Active Topics](https://wordpress.org/support/plugin/calculated-fields-form/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/calculated-fields-form/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/calculated-fields-form/reviews/)

 * 4 replies
 * 2 participants
 * Last reply from: [epenian](https://wordpress.org/support/users/epenian/)
 * Last activity: [10 years ago](https://wordpress.org/support/topic/data-base-calculation-query/#post-7451006)
 * Status: resolved