Print query result on form page
//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...