Displaying data from database I am studying how to create a custom module in Drupal7, so far I have created a simple module that will accept subscribers by registering.

These are the fields I have for my database, and has finished the function that will accept user input.

Table: simple_subscribe

sid , firstname, lastname, email


I then proceeded to create the function that will display all of the subscribers
so far this is what I got

function subscription_view_form() {
  $result = db_query("SELECT * from subscribe");

  $record = $result-&gt;fetchAll();  
  echo '&lt;pre&gt;';
  print_r($record);
  echo '&lt;/pre&gt;';
}


I am using print_r($record); to display the information, but all it displays is the objects on top of the website, before the navigation

Array
(
    [0] =&gt; stdClass Object
        (
            [sid] =&gt; 1
            [firstname] =&gt; John
            [lastname] =&gt; Doe
            [email] =&gt; johndoe@gmale.com
        )

    [1] =&gt; stdClass Object
        (
            [sid] =&gt; 2
            [firstname] =&gt; Test
            [lastname] =&gt; Beta
            [email] =&gt; betatester@delta.com
        )

)


edit

I am using the hook_menu() to display a form on /subscriptions but I can't output the subscribers inside the content area, I also wanted to list it in a table, I only did the print_r($records) to test if it is fetching the data. I wanted to know how to output it properly inside the content area not above it?

function subscription_menu() {
  $items[ 'subscriptions' ] = array( 
    'title' =&gt; 'View the Subscribers', 
    'description' =&gt; 'Subscription form available for subscribers',
    'page callback' =&gt; 'drupal_get_form',
    'page arguments' =&gt; array( 'subscription_view_form' ),
    'access arguments' =&gt; array( 'access content' ),
    'file' =&gt; 'subscription.pages.inc'
  );

  return $items;
I really think you should dive into Drupal's Examples Module to look at how a lot of the hooks and so forth you are (mis)using actually work.

But, quickly:

function subscription_menu() {

  $items=array();

  $items[ 'subscriptions' ] = array( 
    'title' =&gt; 'View the Subscribers', 
    'description' =&gt; 'Subscription form available for subscribers',
    'page callback' =&gt; 'subscription_records',
    'access arguments' =&gt; array( 'access content' ),
    'file' =&gt; 'subscription.pages.inc'
  );

  return $items;

}


and

function subscription_records() {

  $result = db_query('SELECT * FROM {subscribe}');
  $records = $result-&gt;fetchAll();

  $content = '&lt;pre&gt;' . print_r($records, TRUE) . '&lt;/pre&gt;';

  return $content;

}


clean up most of the glaring misunderstandings.

However, you will still need to look into Render Arrays and Dynamic Queries to really clean up your code, as well as the Drupal Theming Guide with special attention to theme_table() to create the page you seem to be after.  And, of course, if you need user input, the Form API Reference is a must. But, once again, all of these are explained and demonstrated in the Examples Module.