What is JotForm?
JotForm is a free online form builder which helps you create online forms without writing a single line of code. No sign-up required.

At JotForm, we want to make sure that you’re getting the online form builder help that you need. Our friendly customer support team is available 24/7.

We believe that if one user has a question, there could be more users who may have the same question. This is why many of our support forum threads are public and available to be searched and viewed. If you’d like help immediately, feel free to search for a similar question, or submit your question or concern.


  • Profile Image

    Configurable list widget to sql database

    Asked by terrywells on January 06, 2016 at 04:35 PM

    Hi, I have managed to work out how to get the form submissions to sql using php. The configurable list widget, predictably, appears in one field. As it seems to be a sub-table within the form is it possible to split it into separate fields in the database using php?

    Thank you.

    This is the php I am using, 'sightings' is the configurable list widget:

    <?php
    // This function will run within each post array including multi-dimensional arrays
    function ExtendedAddslash(&$params)
    {
            foreach ($params as &$var) {
                // check if $var is an array. If yes, it will start another ExtendedAddslash() function to loop to each key inside.
                is_array($var) ? ExtendedAddslash($var) : $var=addslashes($var);
                unset($var);
            }
    }

    // Initialize ExtendedAddslash() function for every $_POST variable
    ExtendedAddslash($_POST);    
    $submission_id = $_POST['submission_id'];
    $formID = $_POST['formID'];
    $ip = $_POST['ip'];
    $name = $_POST['fullname'][0] ." ". $_POST['fullname'][1];
    $email = $_POST['email'];
    $date = $_POST['date5'][0] ."-". $_POST['date5'][1] ."-". $_POST['date5'][2];
    $location = $_POST['location'];
    $sightings = $_POST['sightings'];
    $clickto = $_POST['clickto'];

    $db_host  = "db606819711.db.1and1.com";
        $db_name   = "db606819711";
        $db_username  = "dbo606819711";
        $db_password   = "*************";

        mysql_connect( $db_host, $db_username, $db_password) or die(mysql_error());
    mysql_select_db($db_name);

    // search submission ID

    $query = "SELECT * FROM `sightings` WHERE `submission_id` = '$submission_id'";
    $sqlsearch = mysql_query($query);
    $resultcount = mysql_numrows($sqlsearch);

    if ($resultcount > 0) {
     
        mysql_query("UPDATE `sightings` SET
                                    `fullname` = '$name',
                                    `email` = '$email',
                                    `date5` = '$date',
                                    `location` = '$location',
                    `sightings` = '$sightings',
                    `clickto` = '$clickto'    
                                 WHERE `submission_id` = '$submission_id'")
         or die(mysql_error());
      
    } else {

        mysql_query("INSERT INTO `sightings` (submission_id, formID, IP,
                                                                              fullname, email, date5, location, sightings, clickto)
                                   VALUES ('$submission_id', '$formID', '$ip',
                                                     '$name', '$email', '$date', '$location', '$sightings', '$clickto') ")
        or die(mysql_error());

    }
    ?>

  • Profile Image
    JotForm Support

    Answered by EltonCris on January 06, 2016 at 11:26 PM

    Config List Widget contains multiple fields so you will get a json array data out of it.

    Example:

    So to get the value, it's either you will decode this data into php using json_decode and then use foreach function to get its value. You might find this helpful http://stackoverflow.com/questions/12429029/php-get-values-from-json-encode.

    If you need further assistance, do let us know.