Print query result on form page I'm writing a custom module to obtain an online quote.

The form has an additional button and once it is clicked, a database query runs and print a value.

//My code for custom button
function garden_form_alter( &amp;$form, &amp;$form_state,$form_id ){
if ($form_id == 'webform_client_form_4208') {
$form['actions']['garden_quote']  = array(
    '#type' =&gt; 'submit',
    '#value' =&gt; t('Get online estimate'),
    '#submit' =&gt; array('mymodule_custom_submit'),
);
$form['#validate'][] = 'mymodule_custom_validate'; 
}
}

//Custom submit handler
function mymodule_custom_submit($form, &amp;$form_state) {
$query = db_select('gardenvalue', 'f');
$query-&gt;fields('f', array('total_cost'))
    -&gt;condition('meters', '2', '=');
$result = $query-&gt;execute();
dpm($result);
}


Once the form has been submitted dpm shows the 'meters' value as'db_condition_placeholder_0' and not number 2. What can be the reason? 

Also I would like to show the $result value on a new text field once the form reloads. If we assume this new text field key is 'total_garden' how can I change its' value to $result on form reload?

Thanks in advance!
//My code for custom button
function garden_form_alter(&amp;$form, &amp;$form_state, $form_id ){
    if ($form_id == 'webform_client_form_4208') {
        $form['actions']['garden_quote']  = array(
            '#type' =&gt; 'submit',
            '#value' =&gt; t('Get online estimate'),
            '#submit' =&gt; array('garden_custom_submit'),
        );
        $form['#validate'][] = 'garden_custom_validate'; 
    }
}

//Custom submit handler
function garden_custom_submit($form, &amp;$form_state) {
    $query = db_select('gardenvalue', 'f');
    $query-&gt;fields('f', array('total_cost'))
        -&gt;condition('f.meters', 2, '=');
    $result = $query-&gt;execute();
    dpm($result);
}


You have spacing errors and identation errors, the condition is not pointing to a field in the table, and you have to dig into the results array to extract the value, as far as I know you only can print results in a form with

drupal_set_message(t('your message', 'success'); instead of dpm hope this help you a little bit...