Display the results of a form submit on the same page just under the form

by Rony Samuel   Last Updated October 19, 2019 08:07 AM - source

I have created a form and it takes in 3 values which are Brand, Item and Zipcode. The values are queried and the results are fetched the database table. I want the results to be shown in a table

function form_example_form_submit($form, &$form_state) {
$sql3 = /*my select query*/

$result = db_query($sql3);
$records = $result->fetchAll();

//code to display table

 echo "<table border=1>";
   echo"<tr>";
    echo"<th>Retail Accounts</th>";
    echo"<th>Address</th>";
    echo"<th>City</th>";
    echo"<th>State</th>";
   echo "</tr>";
   foreach ($records as $record) {
    $record     = get_object_vars($record);
    echo "<tr>";
      echo "<td>";
        echo $record['Retail Accounts'];
      echo "</td>";
      echo "<td>";
        echo $record['ADDR'];
      echo "</td>";
      echo "<td>";
        echo $record['CITY'];
      echo "</td>";
      echo "<td>";
        echo $record['STATE'];
      echo "</td>";
    echo"</tr>";    
}
echo "</table>";
}

The result is properly fetched but not displayed on the page.

I tried $form_state['rebuild'] = TRUE; but it displays the result on top of the page.

I want the result to be visible just below my form. How can I achieve that?

Any help is very much appreciated. Thanks in advance.

Tags : 7 forms search


Related Questions


How to create a search form template?

Updated August 24, 2016 08:04 AM



How to retrieve form data?

Updated March 23, 2019 17:07 PM