Hi, i bought a framework website which i am altering for a client and i am trying to add a new feature to it.
i have added new field to mysql table
i have added lines of code to show up on form, the choice in new feature will be 'manual' or 'automatic'.
and im stuck with the code as it keeps adding manual, no matter what i choose.

in mysql i added new field called 'transmissiontype' and data type of 'enum' with length/values set to 'manual' and 'automatic' and set a default of 'manual'

my object is have a select box showing manual and automatic, defaulted to manual.
i have added this line where the form is asking for info, it errors when submitting and im sure this bits wrong, but cannot see the wood for the forrest

        ( isset($_POST['transmissionTypeInput']) ? $transmission_type = (bool)($_POST['transmissionTypeInput']) : $transmission_type = false );
        ( $transmission_type ? $transmission_type = 'manual' : $transmission_type = 'automatic' );

there is another file which is the front end form and the previous code was from a file which is the controller, this next bit of code is from the main form

<!-- adding transmission type **** manual and automatic ****  --> <div class="input-prepend"> <span class="add-on" style="width:150px;overflow:hidden;"><?php echo $_LANG['NEW_VEHICLE_TRANSMISSION_TYPE_LABEL'];?></span> <select name="transmissionTypeInput" style="width:569px;"> <?php
                                $automatic = '';
                                $manual = '';
                                if( isset($_SESSION['vin_session']) ){
                                    if( $_SESSION['vin_session']['automatic'] ){
                                        $automatic = 'selected="selected"';
                                    } else {
                                        $manual = 'selected="selected"';
                            ?> <option value="manual" <?php echo $manual;?>><?php echo $_LANG['NEW_VEHICLE_TRANSMISSION_TYPE_OPTION_MANUAL'];?></option> <option value="automatic" <?php echo $automatic;?>><?php echo $_LANG['NEW_VEHICLE_TRANSMISSION_TYPE_OPTION_AUTOMATIC'];?></option> </select> </div> <!--  end of adding transmission type **** manual and automatic **** -->

my form tells me there is an internal error, i have tried adding debugging, but wont show up

help please obi-wan


see AndrisP answer.

$transmission_type = ( isset($_POST['transmissionTypeInput']) && $_POST['transmissionTypeInput']=='automatic' ? 'automatic' : 'manual' );
commented: I misread OP request and focused on the first bit of code... correct solution +1 +13

thanks for the quick reply,
before i try it there is a big block of code it start like this

    private function saveVehicleForm(){
        ( isset($_POST['stockInput']) ? $stock = trim($_POST['stockInput']) : $stock = '' );
........(lots more issets)
/** -my bit- adding transmission type ***/

        ( isset($_POST['transmissionTypeInput']) ? $transmission_type = (bool)($_POST['transmissionTypeInput']) : $transmission_type = false );
        ( $transmission_type ? $transmission_type = 'manual' : $transmission_type = 'automatic' );

/** end of -my bit- adding transmission type **/
(........(more issets)
        require_once BASE_CLASS . 'class-utilities.php';

the code you guys replyed with is way different, to the surround code, if i change it will it upset the surround flow?

OOP its easy:

class Vehicle {
    public $transmission='manual'; // default value for transmission
    public $doors=4; // default value for doors
    public $engine; // without default value

    private function saveVehicleForm(){
        $this->transmission = $_POST['transmissionTypeInput'];
        $this->doors = $_POST['doors'];
        // etc...

thanks andris,

but this file is 630 lines, there are a handful of other file which are of a similar code structure, i dont want to have to redo all their work, all i want to do is add a select box to a form to choose auto or manual.

just to let you know, with this framework the page i am changing has other files linked to it


as you see this 1 page on the site, it has 5 files liked to it to work correctly, and if i have to change more than 1 page then i have lots to do