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

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"<th>Retail Accounts</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 "</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

Updated August 24, 2016 08:04 AM

Updated May 25, 2016 08:03 AM

Updated April 06, 2015 00:03 AM

Updated March 23, 2019 17:07 PM

Updated March 23, 2017 10:07 AM