We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 32645
    • 377 Posts
    I have the following MySQL table which I want to appear as a simple checkbox template variable.

    // Basic MySQL structure
    id (primary key, int, auto-increment)
    airportcode (varchar (12))
    airportname (varchar (255)
    


    I have created a checkbox template variable;

    // template variable setup
    name: tv_airport
    input type: checkbox
    input options: 
    @SELECT airportname FROM airports ORDER BY airportname ASC
    


    However I do not want to use `AirportName` for both the storage and visual, I want to store `AirportCode` and use `AirportName` for the visual.

    So it stores "AirportCode" in the DB/TV but shows AirportName to the user.

    // Something like this (not exact/correct);
    <input value="airportname" name="airportcode" />
    


    This way I do not have to do any reverse engineering to find out what Airport was actually selected later on.

    Is there a way to do this?

    Another question I have is, am I meant to make the checkbox comma-seperated, and what is the benefit of doing that?

    Thanks.
      • 32645
      • 377 Posts
      I have another question. In a drop down list menu, how do I add"None" to the drop down list and make it the first one in the list and ensure it has no value?

      Variable Name:: tv_airport_name
      Input Type:  Drop Down List Menu
      Input Option Values: 
      @SELECT airportname FROM airports ORDER BY airportname ASC
      Default value: None
      


      Thanks.
        • 21561
        • 16 Posts
        id looks like your @SELECT airportname FROM airports ORDER BY airportname ASC should have airportcode as well.

        @SELECT airportcode, airportname FROM airports ORDER BY airportname ASC


        As for your other question.  I am not sure. If I were doing it i would make a snippet instead of a tv.