How to print the search results after form_submit, in a custom search module? I am creating a custom search block, I have created a form in the block. Here is my form_submit. I need to print a html table of some of the fields in the $result array. I am using Drupal_set_message(), I need to show the results in a table instead, so that user can print the page

$text = $form_state['values']['text'];
$query = db_select('table_1', 'n');
$query-&gt;fields('n', array('id'));
 $query-&gt;fields('n', array('phone'));
$query-&gt;fields('n', array('name')); 
$query-&gt;condition('n.p_id', $text, '=');
$column_name = $query-&gt;execute();
I used an if statement in the form to check if submit is pressed and gave the results in the if block. 

function hook_form($form, &amp;$form_state) {
if (!empty($form_state['values']['text'])) {//here i am checking if the text field is empty
    $header=array('one'=&gt;t('one'),'two'=&gt;t('two'));//your header
 $query=db_query();//query
$column_name = $query-&gt;execute()-&gt;fetchAssoc();//fetchAssoc to get results in an associative array.
//here get the fields from $column name into rows
$row = array( 
    array(
    'one'=&gt;$column_name[""],
    'two' =&gt; $column_name[""],
    );
//your form elements after submit is pressed.  
 $form['table']=array(
 '#theme'=&gt;'table',
 '#header'=&gt;$header,
 '#rows'=&gt;$row,
 );

}
else {
//your original form here.
 $form['text'] = array(
'#type' =&gt; 'textfield'
 );
$form['buttons']['submit'] = array(
'#type' =&gt; 'submit',
'#value' =&gt; t('Submit Button'),

);
  }
 return $form;
}


in you form submit add this 

$form_state['rebuild']=true;